扭曲未检测到客户端断开连接

发布于 2024-10-03 08:59:36 字数 415 浏览 2 评论 0原文

有人有这方面的经验吗?我有一个扭曲的应用程序。客户端连接到服务器。我添加了一项功能,如果客户端连接到服务器,但该 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

‘画卷フ 2024-10-10 08:59:36

这是一个 Twisted 常见问题解答,尽管它与 Twisted 没有任何关系具体来说。

This is a Twisted FAQ, even though it doesn't really have anything to do with Twisted specifically.

许你一世情深 2024-10-10 08:59:36

嘿,我不敢相信我忘记了在网络课上学到的所有东西......

(2:09:44 PM) coworker: this is the expected behaviour
(2:10:15 PM) coworker: the server has no way to know if someone dies, or is just quiet
(2:10:35 PM) coworker: unless ofcourse the server has some kind of ping/keepalive message
(2:15:38 PM) claudiu: ah so if they have no communicatin
(2:15:42 PM) claudiu: there's no way to tell that a TCP connection has died
(2:15:47 PM) claudiu: i remember learning that now, yes..
(2:16:23 PM) claudiu: but if i just make the server ping the client then it'll figure out soon enough from lack of ACKs that it's dead, right?
(2:16:45 PM) coworker: right

Heh I can't believe I forgot all that I learned in networking class...

(2:09:44 PM) coworker: this is the expected behaviour
(2:10:15 PM) coworker: the server has no way to know if someone dies, or is just quiet
(2:10:35 PM) coworker: unless ofcourse the server has some kind of ping/keepalive message
(2:15:38 PM) claudiu: ah so if they have no communicatin
(2:15:42 PM) claudiu: there's no way to tell that a TCP connection has died
(2:15:47 PM) claudiu: i remember learning that now, yes..
(2:16:23 PM) claudiu: but if i just make the server ping the client then it'll figure out soon enough from lack of ACKs that it's dead, right?
(2:16:45 PM) coworker: right
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文