Re: locating blocked port
On Tue, Jan 31, 2023 at 08:31:38AM -0700, Casey Deccio wrote:
>
>
> > On Jan 31, 2023, at 8:05 AM, Haines Brown <haines@histomat.net> wrote:
> >
> > I have an application that refuses to start because its port is
> > blocked. But I have difficulty knowing what port it is
> I would try strace, which shows you all system calls being made. In
> this case, it is probably bind() that is returning an error.
I do
$ strace -e trace=%net java -jar /usr/local/share/JabRef/JabRef-3.2.jar 2>&1 | grep bind
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)
But this does not tell me what is bound to what port.
> For example:
>
> $ cat test.py
> #!/usr/bin/env python3
In /usr/bin there is a jabref file, but it does not specify what port
it uses.
> import socket
> s = socket.socket()
> try:
> s.bind(('0.0.0.0', 56))
> except:
> pass
> $ python3 test.py # doesn't print any output
> $ strace -e trace=%net python3 test.py 2>&1 | grep bind
> bind(3, {sa_family=AF_INET, sin_port=htons(56), sin_addr=inet_addr("0.0.0.0")}, 16) = -1 EACCES (Permission denied)
>
> The value of sin_port is what you are looking for.
My run of the strace command as above does not return the string
sin_port.,
>
> > How do I know from this what port the java application tried to use?
> > 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?
>
> Well, it tells you that nothing (including jabref) is listening on
> TCP port 56, but it won't tell you about why something *failed* to listen. See strace above.
I don't see in refurn for strace that anyhing is not listening to
port 56.
Casey, thanks for your effort to help, but I'm too ill infomred to
benefit from your advice.
--
Haines Brown
/"\
\ / ASCII Ribbon Campaign
X against HTML e-mail
/ \
Reply to: