扭曲未检测到客户端断开连接
有人有这方面的经验吗?我有一个扭曲的应用程序。客户端连接到服务器。我添加了一项功能,如果客户端连接到服务器,但该 IP 地址已经有一个客户端正在运行,它会断开新客户端的连接。
有时,我会关闭客户端计算机(准确地说是虚拟机),而无需手动关闭 Python 程序。当我这样做时,偶尔但经常,服务器不会检测到任何断开连接。当计算机恢复并尝试重新连接时,服务器坚持认为已经存在来自该 IP 的连接。到目前为止我找到的唯一解决方案是重新启动服务器。
没有断开连接会不会是奇怪的网络事物?扭曲的虫子?
我 99% 确定这不是我处理断开连接的代码的错误。我的代码设置为每当连接丢失时都会调用 connectionLost
,包括大多数关闭机器的情况,并且它要么记录一个字符串,说明断开连接的情况,要么在发生奇怪的情况时引发异常。这些事情都没有出现在日志中。
Does anybody have experience with this? I have a twisted app. The clients connect to the server. I added a feature so that if a client connects to a server, but there's already a client from that IP address running, it disconnects the new client.
Once in a while, I shutdown a client computer (or VM, to be precise) without manually turning off the Python program. When I do this, once in a while but pretty often, the server does not detect any disconnect. When the computer comes back up and tries to reconnect, the server insists that there is a connection from that IP already. The only solution I've found so far is to restart the server.
Could it be strange networking things not having the disconnect go through? Twisted bug?
I'm 99% certain it's not a bug with my code to handle disconnects. My code is set up such that connectionLost
is called whenever a connection is lost, including most cases of shutting down a machine, and it either logs a string saying what disconnected or throws an exception if something strange happened. Neither of these things showed up in the log.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是一个 Twisted 常见问题解答,尽管它与 Twisted 没有任何关系具体来说。
This is a Twisted FAQ, even though it doesn't really have anything to do with Twisted specifically.
嘿,我不敢相信我忘记了在网络课上学到的所有东西......
Heh I can't believe I forgot all that I learned in networking class...