ChatExchange
ChatExchange copied to clipboard
500 Error when reading messages
When receiving messages from SE, it raised a 500 error. After this, it no longer read any more messages. This is probably due to the exception killing off the reader
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/user/chatexchange_forward/venv/lib/python3.6/site-packages/chatexchange/browser.py", line 742, in _runner
'events', {'r' + self.room_id: last_event_time}).json()
File "/home/simon/chatexchange_forward/venv/lib/python3.6/site-packages/chatexchange/browser.py", line 133, in post_fkeyed
return self.post(url, data, headers)
File "/home/user/chatexchange_forward/venv/lib/python3.6/site-packages/chatexchange/browser.py", line 113, in post
return self._request('post', url, data, headers, with_chat_root)
File "/home/user/chatexchange_forward/venv/lib/python3.6/site-packages/chatexchange/browser.py", line 102, in _request
response.raise_for_status()
File "/home/user/chatexchange_forward/venv/lib/python3.6/site-packages/requests/models.py", line 935, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 500 Server Error: Internal Server Error for url: https://chat.stackexchange.com/error?aspxerrorpath=/events
Can your reproduce the error now? Chat often has some outtakes and especially this lib has it's issues with it. I'd suggest to wrap the watch()
or the watch_socket()
function in a try ... except
and catch any exceptions you may receive. That should also eliminate crashes when the socket connection dies.
Also, 500 Error codes mostly suggest it's an issue on SE's side (since HTTP errors in the 500 range are server errors)