dj_dwebsocket icon indicating copy to clipboard operation
dj_dwebsocket copied to clipboard

when I close the client, it says:error: [Errno 9] Bad file descriptor

Open wuxie2015 opened this issue 7 years ago • 0 comments

I was using dwebsocket for sending value to fronted continusly, like send a number per 2 seconds and the frontend show new number in the page. When I closed the web page, django says [Errno 9] Bad file descriptor since django take that socket as alive, even I had already closed the websocket connection, how can I fix it? Now I have to capture this exception by myself.


the full error imformation is : Traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 149, in get_response response = self.process_exception_by_middleware(e, request) File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 147, in get_response response = wrapped_callback(request, *callback_args, **callback_kwargs) File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py", line 149, in _wrapped_view response = view_func(request, *args, **kwargs) File "/usr/local/lib/python2.7/dist-packages/dwebsocket/decorators.py", line 16, in new_func response = func(request, *args, **kwargs) File "/usr/local/python_test/test_django/websocket_lin/views.py", line 51, in show_continuesly for message in request.websocket: File "/usr/local/lib/python2.7/dist-packages/dwebsocket/websocket.py", line 55, in iter message = self.wait() File "/usr/local/lib/python2.7/dist-packages/dwebsocket/backends/default/websocket.py", line 87, in wait new_data = self.protocol.read() File "/usr/local/lib/python2.7/dist-packages/dwebsocket/backends/default/protocols.py", line 52, in read _, data = self.read_data() File "/usr/local/lib/python2.7/dist-packages/dwebsocket/backends/default/protocols.py", line 116, in read_data raise EOFError("EOF when reading a line, websocket has been closed") EOFError: EOF when reading a line, websocket has been closed [01/Dec/2017 08:57:32] "GET /show_continuesly/ HTTP/1.1" 500 86661 Traceback (most recent call last): File "/usr/lib/python2.7/wsgiref/handlers.py", line 86, in run self.finish_response() File "/usr/lib/python2.7/wsgiref/handlers.py", line 128, in finish_response self.write(data) File "/usr/lib/python2.7/wsgiref/handlers.py", line 212, in write self.send_headers() File "/usr/lib/python2.7/wsgiref/handlers.py", line 270, in send_headers self.send_preamble() File "/usr/lib/python2.7/wsgiref/handlers.py", line 191, in send_preamble self._write('HTTP/%s %s\r\n' % (self.http_version,self.status)) File "/usr/lib/python2.7/wsgiref/handlers.py", line 391, in _write self.stdout.write(data) File "/usr/lib/python2.7/socket.py", line 328, in write self.flush() File "/usr/lib/python2.7/socket.py", line 307, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) error: [Errno 9] Bad file descriptor [01/Dec/2017 08:57:32] "GET /show_continuesly/ HTTP/1.1" 500 59 Exception happened during processing of request from ('192.168.56.1', 55262) Traceback (most recent call last): File "/usr/lib/python2.7/SocketServer.py", line 596, in process_request_thread self.finish_request(request, client_address) File "/usr/lib/python2.7/SocketServer.py", line 331, in finish_request self.RequestHandlerClass(request, client_address, self) File "/usr/local/lib/python2.7/dist-packages/django/core/servers/basehttp.py", line 99, in init super(WSGIRequestHandler, self).init(*args, **kwargs) File "/usr/lib/python2.7/SocketServer.py", line 654, in init self.finish() File "/usr/lib/python2.7/SocketServer.py", line 713, in finish self.wfile.close() File "/usr/lib/python2.7/socket.py", line 283, in close self.flush() File "/usr/lib/python2.7/socket.py", line 307, in flush self._sock.sendall(view[write_offset:write_offset+buffer_size]) error: [Errno 9] Bad file descriptor

wuxie2015 avatar Dec 01 '17 10:12 wuxie2015