简体   繁体   中英

Handling Socket Exception 10060 on already connected clients

Socket Exception 10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

The vast majority of questions I have read regarding Socket Exception 10060 are in the context of connecting. My server is experiencing the second part of this exception "established connection failed because connected host has failed to respond" .

I have approximately 150 persistent client socket connections. Every so often my server is receiving Socket Exception 10060 on some of these connections. I would say roughly 1-3 of these every 5 minutes. Currently when I get this exception on a socket, I disconnect that socket. I have noticed that within 5 seconds to 3 minutes, the client will re-connect.

Would it be fair to say that the client is actually having a connection problem and not responding?

Should I be disconnecting the client socket when I receive Socket Exception 10060? Or should I be monitoring how many times a particular client/socket receives Socket Exception 10060 and disconnect them after x number of occurences?

If it's only some clients and only some of the time, then it does appear to be that it's those clients have connection issues that's causing the problem.

If that's the case and the clients cope with this situation and reconnect successfully, then handling the exception by disconnecting is the correct approach.

Only disconnecting after a certain number of consecutive exceptions would be sensible as the odd exception could just be a transient problem. Also if the cost of closing and reconnecting (in terms of the time it takes) is relatively high then continually doing this could be expensive.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM