Answer the question
In order to leave comments, you need to log in
How to make friends java, sockets and firewall?
The task is to have a java server. Written in ServerSocket.
There is a client behind a cutting corporate firewall (at work).
If I understand sockets correctly, then the following happens:
1. my server hangs on an open socket (mail 25, for example
) -some other (random?) port (like 25123, different each time).
3. here the client's firewall comes into play and everything breaks off.
Clients without a firewall connect normally.
The question is - can I somehow force the .accept() method to choose a port for a direct connection with the client from the list, and not a random one?
It is clear that this does not roll for mass use. But the task doesn't require it. The goal is to establish a socket connection with several clients behind corporate firewalls.
Answer the question
In order to leave comments, you need to log in
You have an error in the second paragraph. There is no transfer to some other random port. If you use utilities like lsof
or netstat
on the server, you will notice that you have one connection with status LISTEN
, which is the server socket; and many connections with status ESTABLISHED
, which are connected clients. At the same time, on the server side, the port for all of them will be the same. But on the client side, the open port will be different, at the discretion of the one who implements the connection to the server.
The firewall is probably cutting outgoing connections from non-standard ports (and not to non-standard ports).
Generally speaking, if a client has a corporate firewall, then this is most likely for a reason. And if, without the knowledge of their security guards, they use some kind of software that is cut by the firewall, then they are unlikely to pat them on the head when they find out. Therefore, such moments should be agreed with the security guards: if the software is needed, then they will add the necessary rules in the firewall.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question