Note that there are some explanatory texts on larger screens.

plurals
  1. POJava network server and TIME_WAIT
    primarykey
    data
    text
    <p>I have run into a problem with a network server that receives signals from devices my company produces. The device will occasionally reuse the source port that it had just used. This causes the SYN to be dropped by the server. The device then retries until the old socket falls out of TIME_WAIT on the server. The server then SYN-ACKs.</p> <p>The server is written in Java. Unfortunately, modifying the device to cycle ports correctly is not an option, as there are many in the field, and updating the existing units is not an option. The old software was written in C++ and somehow expunged the TIME_WAIT port from the list in the Windows TCP stack.</p> <p>Can anyone offer me any advice on how to circumvent TIME_WAIT from Java on Windows?</p> <p>EDIT: I have indeed confirmed in Wireshark that the device is reusing a recently used port.</p> <p>On the server socket I am using the following options:</p> <pre><code>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); </code></pre> <p>And the client socket has the following set after receiving:</p> <pre><code>Socket client = server.accept(); client.setKeepAlive(false); client.setSoLinger(true, 0); client.setReuseAddress(true); client.setTcpNoDelay(true); client.setSoTimeout(CLIENT_READ_TIMEOUT); </code></pre> <p>I have tried SO_LINGER as both true and false, with the exact same trace results. CLIENT_READ_TIMEOUT is set to 10 seconds.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload