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

bug: requests.request running endless in some cases #149

Closed
lugino-emeritus opened this issue Oct 2, 2017 · 1 comment
Closed

bug: requests.request running endless in some cases #149

lugino-emeritus opened this issue Oct 2, 2017 · 1 comment

Comments

@lugino-emeritus
Copy link

lugino-emeritus commented Oct 2, 2017

My router changes his ip every three days, and then this sdk does not reconnect to the server.
This request method does not return in that case, and so there is also no exception which could be handled.

Solution: add a timeout to the request.
I can do a pull request, but there are some points to discuss:

  • The timeout has to be larger than the timeout defined in the query_params. (if available). Should we use 60 seconds by default (if no timeout is available), otherwise 2*query_params['timeout'] (request_timeout = 2 * query_params.get('timeout', 60000)/1000)
  • Should we handle the possible timeout exception in listen_forever by default?

Moreover I have to search whether there are more requests in this code, and whether it is useful to add a timeout.

@non-Jedi
Copy link
Collaborator

non-Jedi commented Oct 2, 2017

Hi @lugino-emeritus. This is a duplicate of #129. Would love a PR fixing it.
To answer your two points:

  1. Any timeout defined in query_params should override the default timeout
    in the same way we do now with Content-Type in the request headers. We
    should add some reasonable length of time to the one specified in
    query-params for the request timeout rather than multiplying (maybe 10
    seconds).
  2. In any methods (like listen-forever that are designed not to return, we
    should handle the timeout exception (I think listen-forever might be the
    only one, but I'm not sure). Otherwise, an exception should be raised rather
    than auto-retrying. Auto-retrying can be added when Make MatrixClient asynchronous #145 (or another PR
    adding async to the client) is merged.

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

No branches or pull requests

2 participants