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

Bot often ran into Network Error caused by httpx #256

Closed
simonlaw0711 opened this issue Apr 25, 2023 · 5 comments
Closed

Bot often ran into Network Error caused by httpx #256

simonlaw0711 opened this issue Apr 25, 2023 · 5 comments

Comments

@simonlaw0711
Copy link

I am hosting this bot on K8S and it always ran into this error and caused the bot stopped response:
Error:

    return await super().send_message(
  File "/usr/local/lib/python3.8/site-packages/telegram/_bot.py", line 331, in decorator
    result = await func(*args, **kwargs)  # skipcq: PYL-E1102
  File "/usr/local/lib/python3.8/site-packages/telegram/_bot.py", line 760, in send_message
    return await self._send_message(
  File "/usr/local/lib/python3.8/site-packages/telegram/ext/_extbot.py", line 488, in _send_message
    result = await super()._send_message(
  File "/usr/local/lib/python3.8/site-packages/telegram/_bot.py", line 512, in _send_message
    result = await self._post(
  File "/usr/local/lib/python3.8/site-packages/telegram/_bot.py", line 419, in _post
    return await self._do_post(
  File "/usr/local/lib/python3.8/site-packages/telegram/ext/_extbot.py", line 326, in _do_post
    return await self.rate_limiter.process_request(
  File "/usr/local/lib/python3.8/site-packages/telegram/ext/_aioratelimiter.py", line 247, in process_request
    return await self._run_request(
  File "/usr/local/lib/python3.8/site-packages/telegram/ext/_aioratelimiter.py", line 203, in _run_request
    return await callback(*args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/telegram/_bot.py", line 450, in _do_post
    return await request.post(
  File "/usr/local/lib/python3.8/site-packages/telegram/request/_baserequest.py", line 165, in post
    result = await self._request_wrapper(
  File "/usr/local/lib/python3.8/site-packages/telegram/request/_baserequest.py", line 288, in _request_wrapper
    raise exc
  File "/usr/local/lib/python3.8/site-packages/telegram/request/_baserequest.py", line 274, in _request_wrapper
    code, payload = await self.do_request(
  File "/usr/local/lib/python3.8/site-packages/telegram/request/_httpxrequest.py", line 223, in do_request
    raise NetworkError(f"httpx.{err.__class__.__name__}: {err}") from err
telegram.error.NetworkError: httpx.RemoteProtocolError: <ConnectionTerminated error_code:ErrorCodes.NO_ERROR, last_stream_id:95, additional_data:None>

Every time i need to fix it by restarting the pod

I have done some research online they said upgrading the httpx modules helps, but i don't familar with this package.

@karfly
Copy link
Collaborator

karfly commented Apr 25, 2023

@simonlaw0711

I created branch http-version with possible fix of your problem. To apply updates:

git pull
git checkout http-version

Please, write here if it helps or not.

@simonlaw0711
Copy link
Author

It works, thanks a lot @karfly

@RaflyLesmana3003
Copy link

hey @karfly , can i know whats the different between the main version and the http-version?

@karfly
Copy link
Collaborator

karfly commented Jun 20, 2023

@RaflyLesmana3003 you can see changes here: 28e7426

@karfly karfly closed this as completed Jun 20, 2023
@bigbabybubble
Copy link

@RaflyLesmana3003 you can see changes here: 28e7426

update python-telegram-bot 20.3

https://docs.python-telegram-bot.org/en/stable/changelog.html
Revert to HTTP/1.1 as Default and make HTTP/2 an Optional Dependency (#3576)

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

4 participants