我正在使用python聊天室服务器from this code但是我在运行客户端的异常行为时出现问题,当我的Android客户端切换到另一个网络然后我的服务器挂起并停止工作切换回聊天服务器网络。 首先我得到错误
error is [Errno 131] Connection reset by peer
然后
error: [Errno 9] Bad file descriptor
我想在聊天服务器代码中处理此问题,并始终保持运行,无论是客户端连接还是断开连接, 详细的例外是
---------------------------------------------
error is [Errno 131] Connection reset by peer
---------------------------------------------
Exception happened during processing of request from ('192.168.2.46', 43160)
Traceback (most recent call last):
File "/usr/local/lib/python2.7/SocketServer.py", line 582, in process_request_thread
self.finish_request(request, client_address)
File "/usr/local/lib/python2.7/SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/lib/python2.7/SocketServer.py", line 640, in __init__
self.finish()
File "/home/rahulm/datagroup.py", line 242, in finish
self.roomcast('\n %s has disconnected *\n' % self)
File "/home/rahulm//datagroup.py", line 341, in roomcast
listener.request.send(data)
error: [Errno 32] Broken pipe
----------------------------------------
error is [Errno 9] Bad file descriptor
----------------------------------------
Exception happened during processing of request from ('192.168.2.63', 40460)
Traceback (most recent call last):
File "/usr/local/lib/python2.7/SocketServer.py", line 582, in process_request_thread
self.finish_request(request, client_address)
File "/usr/local/lib/python2.7/SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/lib/python2.7/SocketServer.py", line 640, in __init__
self.finish()
File "/mnt/usb/PirateBox/Shared/datagroup.py", line 242, in finish
self.roomcast('\n %s has disconnected *\n' % self)
File "/mnt/usb/PirateBox/Shared/datagroup.py", line 341, in roomcast
listener.request.send(data)
File "/usr/local/lib/python2.7/socket.py", line 170, in _dummy
raise error(EBADF, 'Bad file descriptor')
error: [Errno 9] Bad file descriptor
----------------------------------------
注意: - 我在嵌入式设备中运行聊天服务器所以我不能使用Twisted 任何帮助最感激。 提前致谢 !!!