I use HAProxy which sends health check every 10 seconds.
It goes in the following fashion:
HAProxy -> server: [SYN]
server-> HAProxy : [SYN, ACK]
HAProxy->server : [RST, ACK]
My TCP server is written in java in the following way:
while (true){
Socket socket = kaServerSocket.accept();
MyListener listener = new MyListener(socket);
listener.start(); //costly operation
}
On windows 7, accept()
does not return after this exchange (it returns after the regular syn->ack->syn handshake), and that's what I need.
However, when the application is running on Windows server 2012, accept()
function returns on the first [SYN]
which is sent from HAProxy, and performs the costly operation.
So I have 2 questions:
Is this behavior configurable?
If I don't want to wait for the first bit or message before I run the listener, how can I detect the connection is from HAProxy on windows 2012?
EDIT:
May it be connected to the ATM TCP/IP on Windows?
https://msdn.microsoft.com/en-us/library/windows/desktop/ms737526(v=vs.85).aspx
When using the accept function, realize that the function may return before connection establishment has traversed the entire distance between sender and receiver. This is because the accept function returns as soon as it receives a CONNECT ACK message; in ATM, a CONNECT ACK message is returned by the next switch in the path as soon as a CONNECT message is processed (rather than the CONNECT ACK being sent by the end node to which the connection is ultimately established). As such, applications should realize that if data is sent immediately following receipt of a CONNECT ACK message, data loss is possible, since the connection may not have been established all the way between sender and receiver.