扭曲未检测到客户端断开连接 [英] twisted not detecting client disconnects

查看:97
本文介绍了扭曲未检测到客户端断开连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人对此有经验吗?我有一个扭曲的应用程序.客户端连接到服务器.我添加了一个功能,以便如果客户端连接到服务器,但是已经有一个客户端从该IP地址运行,它将断开新客户端的连接.

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.

一段时间后,我关闭了客户端计算机(准确地说是VM),而没有手动关闭Python程序.执行此操作时,服务器偶尔会偶尔但很少检测到任何断开连接.当计算机重新启动并尝试重新连接时,服务器坚持认为该IP已经存在连接.到目前为止,我发现的唯一解决方案是重新启动服务器.

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?

我有99%的把握可以解决断开连接的代码不是错误.我的代码设置为在连接断开时(包括大多数关闭计算机的情况)都调用connectionLost,并且它记录一个字符串说明断开连接的情况,或者在发生奇怪的情况时引发异常.这些东西都没有出现在日志中.

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.

推荐答案

这是一个 Twisted FAQ ,尽管它实际上与Twisted没有任何关系.

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

这篇关于扭曲未检测到客户端断开连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆