How to check if inbound port is in use - sockets

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/

Related

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

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

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)

How can I detect what program is listening to a TCP/IP port in Windows?

I have an application that I inherited that listens on port 7001 for UDP broadcasts from our in-house test equipment, and I recently updated another application that needs to do the same thing. Both applications must be able to coexist on the same computer.
Currently, when my recently updated application attempts to bind to the port to listen for UDP broadcasts and fails, it simply reports that the port is not available and suggests that the inherited application is probably running. How can I get my application to detect what application is actually listening on that port? I've done a Google search and have even searched this site, but so far I have been unable to find anything except to use Task Manager, TCPView, or netstat at the command line.
I would prefer a technique that either uses the Windows API or a Windows system COM component, since both applications are written in Visual Basic 6.0. (I know, I know, but I must maintain these applications since they are mission critical.) However, a .NET solution would would also be useful in case I need it in my new development efforts.
Use:
netstat -n -o
That will show the process ID and from there you can either look in the Task Manager's process viewer, go to menu View → Columns... and check the Process ID (PID). Then you can see the name of the process listening on that port.
Of course, you're wanting a programmatic way of accomplishing this and the GetTCPTable2 API is best as was already suggested. In fact, if you look at the IAT (Import Address Table) for netstat.exe, it actually uses that API to get that information.
There is a way to communicate directly with a command window and get its output using pipes and it would work fine, but the ideal way is to simply use the same API netstat uses.

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.

Using Wireshark With Local Test Application

I have written a small client server socket application. It is a proof of concept for some socket programming that I want to apply to a much bigger project.
For the moment I want to user wireshark to analyse the traffic that goes between them. They are both running on my local machine.
I have installed a loopback interface, and have tried to use wireshark with it.
No joy. Any ideas?
I have successfully analysed traffic between my machine and other machines no problems.
I have had a look here,
http://wiki.wireshark.org/CaptureSetup/Loopback
And I am not using the address 127.0.0.1 which they mention saying you can't capture traffic on 127.0.0.1
Thanks.
You might try creating a virtual machine to run your application and using wireshark on it.
Save yourself some grief and download Microsoft Network Monitor.
As good as Wireshark is on Unixen, Windows is a "special" case :)