简体   繁体   English

在已连接的客户端上处理套接字异常10060

[英]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 套接字异常10060: 连接尝试失败,因为一段时间后被连接方未正确响应,或者建立连接失败,因为连接的主机未能响应

The vast majority of questions I have read regarding Socket Exception 10060 are in the context of connecting. 我阅读的有关Socket Exception 10060的绝大多数问题都与连接有关。 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. 我大约有150个持久客户端套接字连接。 Every so often my server is receiving Socket Exception 10060 on some of these connections. 我的服务器每隔一段时间就会在其中一些连接上收到套接字异常10060。 I would say roughly 1-3 of these every 5 minutes. 我每5分钟大概说1-3次。 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. 我注意到,客户端将在5秒到3分钟内重新连接。

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? 收到套接字异常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? 还是我应该监视特定的客户端/套接字接收到Socket Exception 10060的次数,并在x次发生后断开它们的连接?

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. 同样,如果关闭和重新连接的成本(就花费的时间而言)相对较高,那么连续执行此操作可能会很昂贵。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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