mrjoes / tornadio2

Python socket.io server implementation on top of Tornado framework
Other
523 stars 118 forks source link

Server logging and slow server work. #70

Closed toxi-kb closed 11 years ago

toxi-kb commented 11 years ago

Hello! We develop a web application based on tornadio2. In the main the application works stable but it gives some mistakes rather often. The list of the mistakes is below. As we see there are no references to the our code and we can’t understand what give that mistakes. Sometimes (rhythmically) the application gives as a lot of such mistakes (frequency of mistakes increases in times) that makes server work slowly. We think that the main operation that makes server slower is logging. Can you tell us if we think correct and the logging slows the server? Can you give us an advise how to avoid or reduce such mistakes? We looked for the answer at thematic forums and among the issues to the libraries tornado and tornadio2 and had found some statements. The statements tell us that such mistakes are not critical, don’t affect the client-server communication and don’t give any negative effect. Is it true? If it’s true how can we suppress or inhibit the logging process?


ERROR:tornado.application:Exception in callback 
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/tornado/ioloop.py", line 453, in _run_callback
    callback()
  File "/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py", line 241, in wrapped
    callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/tornado/iostream.py", line 316, in wrapper
    callback(*args)
  File "/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py", line 241, in wrapped
    callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/tornado/httpserver.py", line 217, in _on_connection_close
    callback()
  File "/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py", line 241, in wrapped
    callback(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/tornado/websocket.py", line 256, in on_connection_close
    self.on_close()
  File "/usr/local/lib/python2.7/dist-packages/tornadio2/persistent.py", line 151, in on_close
    self._detach()
  File "/usr/local/lib/python2.7/dist-packages/tornadio2/persistent.py", line 117, in _detach
    self.session.remove_handler(self)
  File "/usr/local/lib/python2.7/dist-packages/tornadio2/session.py", line 173, in remove_handler
    raise Exception('Attempted to remove invalid handler')
Exception: Attempted to remove invalid handler

ERROR:tornado.application:Uncaught exception in /socket.io/1/websocket/ce83bfa8b8109109f5d4a278204558ec
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/tornado/websocket.py", line 285, in wrapper
    return callback(_args, *_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/tornadio2/persistent.py", line 87, in open
    raise HTTPError(401, "Invalid Session")
HTTPError: HTTP 401: Unauthorized (Invalid Session)

ERROR:tornado.application:Exception in callback 
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/tornado/ioloop.py", line 453, in _run_callback
    callback()
  File "/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py", line 241, in wrapped
    callback(_args, *_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/tornado/iostream.py", line 316, in wrapper
    callback(_args)
  File "/usr/local/lib/python2.7/dist-packages/tornado/stack_context.py", line 241, in wrapped
    callback(_args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/tornado/httpserver.py", line 320, in _on_headers
    self.request_callback(self._request)
  File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 1479, in __call__
    handler._execute(transforms, _args, *_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/tornadio2/persistent.py", line 81, in _execute
    super(TornadioWebSocketHandler, self)._execute(transforms, _args, *_kwargs)
  File "/usr/local/lib/python2.7/dist-packages/tornado/websocket.py", line 143, in _execute
    self.ws_connection.accept_connection()
  File "/usr/local/lib/python2.7/dist-packages/tornado/websocket.py", line 492, in accept_connection
    self._accept_connection()
  File "/usr/local/lib/python2.7/dist-packages/tornado/websocket.py", line 541, in _accept_connection
    self._receive_frame()
  File "/usr/local/lib/python2.7/dist-packages/tornado/websocket.py", line 582, in _receive_frame
    self.stream.read_bytes(2, self._on_frame_start)
  File "/usr/local/lib/python2.7/dist-packages/tornado/iostream.py", line 162, in read_bytes
    self._try_inline_read()
  File "/usr/local/lib/python2.7/dist-packages/tornado/iostream.py", line 393, in _try_inline_read
    self._check_closed()
  File "/usr/local/lib/python2.7/dist-packages/tornado/iostream.py", line 543, in _check_closed
    raise StreamClosedError("Stream is closed")
StreamClosedError: Stream is closed
mrjoes commented 11 years ago

Sorry for late response, but it looks like you have load balancer and it is improperly configured. Do you have sticky sessions enabled?

First exception is weird and should not happen. How often does it happens?

Second exception looks like it is problem with load balancer.

Third exception is not something you can fix - WebSocket connection getting closed due to networking problem.