I have a java process that make use of ServerSocket API (Java 8) and bind to the local port 12000. Process runs under a Windows service Wrapper (exe4j). I have a scheduled task that runs at 4am that stop the service and restart it after a couple of seconds. That process is installed over 400 customers locations.
Everything was running smooth until about last friday. A few processes failed to restart properly at 4am. On 2 servers I was able to connect and verify, the restart failed with both a "Address already in use: JVM_Bind". It's seems that the port 12000 was still in use by a the system.
I used every tools (processexplorer, tcpview, netstat -ano, name it) I know to try to find the process... with no success. Only a machine reboot fixed the issue. But problem came back a night or two later.
After some reading, I saw that I was doing a sockect.accept()
with infinite timeout so I changed it for
socket.setSoTimeout(15000);
socket.accept();
instead.
I putted the new version in place but the problem is still there.
Machines got Windows updates. I did tests with the same Windows version fully updated but I can't reproduce.
I'm out of solution now.
Any ideas Thanks
A windows update affected the release of address/port after process shutdown.
Refer to Address Bind exception in Tomcat for solution.