Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSONDecodeError when trying to interact with user in a non-healthy server #282

Open
andrevmatos opened this issue Sep 26, 2018 · 2 comments

Comments

@andrevmatos
Copy link

We got a small federation running for Raiden Network, and because of some disk full issue, one of the servers crashed. Following it, the healthy ones started returning some unexpected responses for interactions with users on the healthy ones.
E.g. trying to invite an user in the unhealthy server to a room in the healthy one, the invite request returned:

<Response [429]>
{"errcode":"M_UNKNOWN","error":"Unknown Status"}

but from

try:
errordata = json.loads(response.json()['error'])
waittime = errordata['retry_after_ms'] / 1000
except KeyError:
pass

if the error isn't a json, json.JSONDecodeError will be raised.
Quick fix is to add json.JSONDecodeError to the handled errors in L734
Full stack traces and context can be found in raiden-network/raiden#2603

@MyDev45
Copy link

MyDev45 commented Nov 27, 2018

Hi @andrevmatos !

I'm getting the same error while trying to connect to a server. What did you exactly do to solve the problem? I can't get it work.

Here is the piece of code i modified tonight:
try: waittime = response.json()['retry_after_ms'] / 1000 except KeyError: try: errordata = json.loads(response.json()['error']) waittime = errordata['retry_after_ms'] / 1000 except json.JSONDecodeError: pass except KeyError: pass sleep(waittime) else: break

Style get the same "simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)" problem.

Thanks by advance !

@andrevmatos
Copy link
Author

Hi, @MyDev45 . my solution for now was to handle the exception myself and implement a retry loop, outside matrix_client. The patch should be simple though, if you can fork or reinstantiate the classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants