Play 1.2.4.3: How to find currently used port for debugger? - eclipse

I have several Play applications running parallel. One of them is running in Eclipse. I want to connect the Eclipse debugger (launcher "Connect JPDA to myapplication.launch"), but the port changes every time (probably due to one of the other applications blocking the default port). I would edit the launcher and enter the current port manually*, but: How would I know which port to use?
PS: As my app runs for quite a while I do not see the port initially displayed in the console anymore.
*PPS: Is there a more elegant way to handle this?

The more elegant way of handling this is to just define the jpda port it should use yourself, so you always know behind which jpda port an application is running and you don't have to look it up all the time. Its documented in the configuration manual and it comes down to adding jpda.port=???? in your application.conf (changing the question marks into a port number, ofcourse).
The reason they change is indeed because they are running in parallel. Java automatically switches to the next available port if the default is in use.

There should be a line in the output log that looks like the following:
Listening for transport dt_socket at address: <some port number>
That's the debug port number you need to configure in Eclipse for JPDA.

OK, in OS X you'll find the port in the activity monitor: Double click each "java" process until you find the one belonging to Eclipse. The requested port is the one mapped to "*".
Click here for details (in German) and screenshots (I need 10 reputation to post images or more than two links)

Related

Could not start GlassFish Server4.1 HTTP or HTTPS Listener port is occupied while server is not running ON A MAC

Could anyone shed some light on this? I have watched a few YouTube videos with the same problem but all solutions are based on Windows. How could I fix this on a Mac? I'm pretty sure I have no other servers running.
Thanks
see error image from netbeans
This means that there is another application using the ports the Glassfish requires. Use the command
lsof -nP -iTCP:$PORT | grep LISTEN
to list the what ports are in use along with the process ID of the process using the port. Glassfish requires ports 4848, 8080 and 8081 to be free. One app that sometimes causes port issues is vnc, so check if you have screen sharing turned on and try disable it if that is the case.

Change Listen Address Web Logic

I have a server running on weblogic 12c. But it is running on localhost:7001/myapp/.. I can run it by http://localhost:7001/myapp/... or http://127.0.01/myapp/... But only on the computer that weblogic is installed. I need to access from other computers. I have changed the Listen Address from localhost to my public IP, but when i did it, my server did not run anymore, it shows an error "Could not find lock file. Maybe the server is already running" something like that. I have already tried to delete the .lok file, but that did not work either. Tried to change the config.xml file, but that did not work either. Have this happenned to someone? How do I fix this?
I faced the same issue and below the answer, for stand alone Weblogic and even for embedded one, You want to change Listen Address, Just do the following steps:
If you have not already done so, in the Change Center of the Administration Console, click Lock & Edit (see Use the Change Center).
In the left pane of the Console, expand Environment and select Servers.
On the Servers page, click the name of the server.
Select Configuration > General.
On the Severs: Configuration: General page, enter a value in Listen Address.
Click Save.
To activate these changes, in the Change Center of the Administration Console, click Activate Changes.
Not all changes take effect immediately—some require a restart (see Use the Change Center).
For (integrated weblogic only) on JDeveloper, open Application servers from windows menu, select Integrated weblogic, right-click on it, select Properties, select Configuration tab, Change hostname with the same IP address you put in Console
if your Weblogic server isn't production server, just ignore steps (1 & 7)
reference : https://docs.oracle.com/cd/E50629_01/wls/WLACH/taskhelp/channels/ConfigureListenAddresses.html
First you need to check what is running on 7001 port:
On windows use: netstat -ano|find /i "7001" it will give you something like :
TCP 0.0.0.0:7001 0.0.0.0 TIME_WAIT 1028
then you can kill that process using
taskkill /F /PID 1028 (java process started on 7001)
Now try to delete *.lok file from Domain/servers/AdminServer Path
and start admin server .
If you have nothing specified in listen address field it will listen on all the available network interfaces which can be check by ipconfig command on window
On linux use netstat -tulp|grep 7001 to find process
Did you see check if there is another application running on your public ip and the same port ?
Your Question is not at all clear. You say your server is running on a server and you can access it using the url http://localhost:7001/myapp/...
So that bit is clear.
Then you try to access your application from another machine. This where it gets confusing.
You say - "I have changed the Listen Address from localhost to my public IP, but when i did it, my server did not run anymore, it shows an error "Could not find lock file. Maybe the server is already running" something like that."
Why would your server stop running if all you did was try to access from a different machine ?
" The error could not find lock file " is usually seen when you try to start a server on a machine where there might be another server already running. But since your aim is only to access your already running server from a different machine you would do that using a browser, why start another instance ?
Could you throw some more light on what exactly you are doing and the result.
Few tips -
Check the listen address of your weblogic server from admin console.
Check if the server you are running weblogic has more than 1 ip. Run ifconfig or ipconfig to get the IP's

How to check if inbound port is in use

I'm developing Firefox addon that communicate with external program by sockets. This program create local socket server on specified port when this addon need it. I would like to ckeck from this addon whether this application has opened this port already.
On Win7 when server isn't created yet I receive in socket created by addon NS_ERROR_CONNECTION_REFUSED in nsIRequestObserver::onStopRequest but if I can feel certain port isn't open when I receive this error?
You try to connect and see if the connection succeeds.
If it doesn't, then the port is not reachable (open).
That's the most obvious and easiest answer.
Other low-level solutions would require polling the OS itself somehow. That would be cross platform specific (so you'd need to write an implementation per platform) and also there is no API readily available so you'd have to mess around with C/C++ or at least js-ctypes, or hack together some ugly "execute this program and check output" stuff. All of which doesn't worth the fuzz.
If you want to find out which "inbound ports" are in use in windows you can use cmd,
if you don't know how to open cmd - open the run dialog by pressing windows-key+r. type cmd and hit enter
type netstat -a and hit enter and it will list all "listening" ports.
more info - http://www.techrepublic.com/blog/it-security/list-open-ports-and-listening-services/

Netbeans & Eclipse hang when I attempt remote EC2 debugging via Xdebug

Already, I've checked at least 20 resources and am out of ideas:
I have a clean, remote Ubuntu EC2 instance, fresh from the AMI, having stopped only to install LAMP, phpmyadmin, and xdebug on it. Yes, I have configured my remote EC2 instance's php.ini file as follows:
Meanwhile, back on my laptop I have Netbeans & Eclipse installed. While I can get either to seamlessly upload and Run my php web app on my EC2 site (via SSH/SFTP) as soon as I hit "Debug" from either, index.php gets uploaded, a browser window opens, and then NOTHING HAPPENS. The page doesn't load, the Debug perspective doesn't open, breakpoints don't get triggered, nothing. Netbeans just hangs out saying "waiting for connection" whereas Eclipse just sits at the notorious 57% level (& yes, I toggled the xdebug.idekey before testing with Eclipse)).
So I tested xdebug's functionality on my server according to the instructions found here and here (both passed). I tried changing to port 9001 (in remote php.ini as well as in local Netbeans/Eclipse), I even tried launching this brand spanking-new EC2 instance with pretty much open Security group settings (SSH=0.0.0.0/0), but nothing seems to be working. I am out & out flummoxed, a self-confessed noob, and appreciative of any insight seasoned professionals in the community may have to offer.
Thanks,
Debbie
This feels like a networking issue to me. Port 9000 may not be accessible. The quickest way to test is to telnet to port 9000 on the remote system (if you have a telnet client installed that allows you to specify which port to telnet to). If the telnet attempt times out or is closed by the remote system you will see the error and this verifies that there is a networking issue.
I would check /etc/services to make sure that port 9000 is not reserved for use of something else. If port 9000 exists and is uncommented then something else is using the port and that services does not know how to respond to your request so it hangs.
I would do a netstat (lookup params to see "all" listening ports) and make sure the remote system is listening on port 9000. If you don't see port 9000 then the remote system is not configured to establish the connection.
If you are on a WIFI network then port 9000 may need to be port forwarded to the remote system using the internal cable modem configuration menu/utility. This is the scenerio I favor because I've wasted so much time solving this kind of problem with different software.
Good luck, you have more troubleshooting ahead of you and different questions to ask to resolve your problem.

Debugging Play with Eclipse

I am trying to debug my Play application with Eclipse. First I launch it using Run As: Application.launch
That seems to work.
Then I try to connect the debugger using Debug As: Connect JPDA to Application.launch
and I get the error message:
"Failed to connect to remote VM. Connection refused.
Connection refused: connect"
Any idea how to make this work?
As stated in another answer, the error you are getting is exactly the same one that you get when you attempt to connect the debugger for a second time when it is actually already connected.
That being said, if it doesn't seem to explain your case, look for this line when you initially start the application via Run As --> Application.launch:
Listening for transport dt_socket at address: 8000
It tells you on which port it is listening for possible JPDA connections, and if this line is missing then something is wrong. You can modify the Application.launch configuration manually (look at the address part of -Xrunjdwp parameter passed to Java virtual machine) and change the port if necessary. If you make changes you also need to update the Connect JPDA to Application.launch run configuration.
Anyways, that is my suggestion - check that the application is indeed listening for possible debugger connections, and try changing the port that is being used for the purpose.
Check that your application mode is set to dev in your conf/application.conf:
application.mode=dev
Start your application and you should see the following:
Listening for transport dt_socket at address: 8000
Right click on the "Connect JPDA.." launcher and Debug As "Connect JPDA..."
I have recieved this error in the past when i have forgotten that the debugger was already connected. Perhaps it is being launched in another way? Also is it possible that debugging is disabled in the app.conf? Just a few things I would check on.
I always run from the command line and debug from Eclipse, might be worth a tray as well. Also try running in test mode if you aren't.
Shutdown everything and run it again. What happens is that when you execute the debug it does not show you anything and you might think nothing happens. You get this error because you might tried several times and you don't know it is already running.
Firstly you have to start play from console not run as. Then start debugger run as.