[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: locating blocked port



Hello

On 2023-01-31 16:05, Haines Brown wrote:
I have an  application that refuses to start because  its port is
blocked. But I have difficulty knowing what port it is

   $ java -jar /usr/local/share/JabRef/JabRef-3.2.jar &
  [1] 4831
  haines@lenin:~$ Jan 31, 2023 8:36:39 AM
net.sf.jabref.logic.remote.server.Remote
  ListenerServerLifecycle open
  WARNING: Port is blocked
  java.net.BindException: Address already in use
        at java.base/sun.nio.ch.Net.bind0(Native Method)
        at java.base/sun.nio.ch.Net.bind(Net.java:555)
        at java.base/sun.nio.ch.Net.bind(Net.java:544)
at java.base/sun.nio.ch.NioSocketImpl.bind(NioSocketImpl.java:643)
        at java.base/java.net.ServerSocket.bind(ServerSocket.java:388)
at java.base/java.net.ServerSocket.<init>(ServerSocket.java:274)
        at
net.sf.jabref.logic.remote.server.RemoteListenerServer.<init>(RemoteListenerServer.java:40)
        at
net.sf.jabref.logic.remote.server.RemoteListenerServerThread.<init>(RemoteListenerServerThread.java:33)
        at
net.sf.jabref.logic.remote.server.RemoteListenerServerLifecycle.open(RemoteListenerServerLifecycle.java:41)
        at net.sf.jabref.JabRef.start(JabRef.java:137)
        at net.sf.jabref.JabRefMain.main(JabRefMain.java:8)

  Arguments passed on to running JabRef instance. Shutting down.

How do I know from this what port the java application tried to use?

I try:

  $ strings $(which jabref) | wc -l
    56

  So I try:

    $ sudo ss -pt state listening 'sport = :56'
    Recv-Q   Send-Q    Local Address:Port   Peer Address:Port Process

  This seems a null return. Dores this mean jabref is not using port
  56?


If ss, or lsof, or any other tool that shows used ports doesn't show port 56 being used. Then it's not being used. Or in your case, since you're filtering ss output to only listening TCP ports, IF it being used, it might be on a different state that "listening". Or it could be UDP, but I'm assuming you except jabref to use a TCP port, thus the use of '-t' option (Disclaimer, I don't what protocols jabref uses)

However I'm not sure what makes you think jabref is trying to use (either TCP or UDP) port 56. It your example you didn't show or tell what to tried to determine it's supposed to use that specific port. wc -l counts lines and have nothing to do with port numbers. So

$ command | wc -l

Returns the number of lines outputted by "command" (whatever before pipe). In your case, "strings $(which jabref)" outputs 56 lines.

"sudo lsof -i" as a sudoer user, or "lsof -i" as root (elevated privileges required to trace used ports) should list processes/commands using ports, for both listening and established. OR just "sudo ss -pt state listening" without specifying a source port to see all the listening port to use used ports, then compare it to 'whatever port number' jabref's documentations says the software uses.

Also, starting jabref with strace, using the network filter, something like "sudo strace -f -e trace=network $InsertHereWhateverCommandYouUseToStartJabref", should help you to see what port it's trying to use.


Reply to: