I have a problem with a network server that receives signals from devices that my company produces. The device will sometimes use the source port that it just used. This results in a SYN reset by the server. The device then retries until the old server drops out of TIME_WAIT on the server. Then the SYN-ACK server.
The server is written in Java. Unfortunately, changing the device for the correct port loop is not an option, since there are many, and updating existing blocks is not an option. The old software was written in C ++ and somehow removed the TIME_WAIT port from the list on the Windows TCP stack.
Can anyone offer me any tips on how to get around TIME_WAIT from Java on Windows?
EDIT: I really confirmed in Wireshark that the device is reusing the recently used port.
In the server socket, I use the following parameters:
socket = new ServerSocket(); socket.setPerformancePreferences(3, 2, 1); socket.setReuseAddress(true); socket.setSoTimeout(CLIENT_READ_TIMEOUT); socket.bind(new InetSocketAddress(group.getPort()), MAX_TCP_BACKLOG);
And after that, the client socket has the following set:
Socket client = server.accept(); client.setKeepAlive(false); client.setSoLinger(true, 0); client.setReuseAddress(true); client.setTcpNoDelay(true); client.setSoTimeout(CLIENT_READ_TIMEOUT);
I tried SO_LINGER both true and false, with the same trace results. CLIENT_READ_TIMEOUT set to 10 seconds.
Alex source share