httpx.ConnectTimeout

See original GitHub issue

Most of the time, everything looks pretty good. But this httpx.ConnectTimeout happens occasionally. I wonder if this has anything to do with my sender setup though.

  File "/usr/local/lib/python3.7/site-packages/tekore/_sender/client.py", line 78, in wrapper
    response = self.send(request)
  File "/usr/local/lib/python3.7/site-packages/tekore/_client/base.py", line 70, in send
    return self.sender.send(request)
  File "/usr/local/lib/python3.7/site-packages/tekore/_sender/extending.py", line 297, in send
    fresh = self.sender.send(request)
  File "/usr/local/lib/python3.7/site-packages/tekore/_sender/extending.py", line 86, in send
    r = self.sender.send(request)
  File "/usr/local/lib/python3.7/site-packages/tekore/_sender/concrete.py", line 41, in send
    data=request.data,
  File "/usr/local/lib/python3.7/site-packages/httpx/_client.py", line 674, in request
    request, auth=auth, allow_redirects=allow_redirects, timeout=timeout
  File "/usr/local/lib/python3.7/site-packages/httpx/_client.py", line 704, in send
    request, auth=auth, timeout=timeout, allow_redirects=allow_redirects
  File "/usr/local/lib/python3.7/site-packages/httpx/_client.py", line 733, in _send_handling_redirects
    request, auth=auth, timeout=timeout, history=history
  File "/usr/local/lib/python3.7/site-packages/httpx/_client.py", line 769, in _send_handling_auth
    response = self._send_single_request(request, timeout)
  File "/usr/local/lib/python3.7/site-packages/httpx/_client.py", line 803, in _send_single_request
    timeout=timeout.as_dict(),
  File "/usr/local/lib/python3.7/contextlib.py", line 130, in __exit__
    self.gen.throw(type, value, traceback)
  File "/usr/local/lib/python3.7/site-packages/httpx/_exceptions.py", line 359, in map_exceptions
    raise mapped_exc(message, **kwargs) from exc  # type: ignore
httpx.ConnectTimeout: The handshake operation timed out

For reference, here’s the sender that I’m using.

sender = tk.CachingSender(max_size=256, sender=tk.RetryingSender(retries=3))
app_token = cred.request_client_token()
spotify = tk.Spotify(token=app_token, sender=sender)

Anything suspicious?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
alexpoguecommented, Jun 9, 2021

I faced this same issue and increasing the timeout seemed to fix the issue:

    # increase the timeout to prevent spotify timeouts
    big_timeout_client = httpx.Client(timeout=60.0)
    big_timeout_sender = SyncSender(big_timeout_client)

    return Spotify(app_token, sender=big_timeout_sender)

I did have to dig a while to find this Github issue and the resolution steps. I wonder if having it in the documentation or examples somewhere would make it more visible to newcomers.

1reaction
Pfed-progcommented, Jul 1, 2021

cheers, timeout=60.0 solved similar issue that I faced with parsing hh.ru .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Advanced Usage - HTTPX
The connect timeout specifies the maximum amount of time to wait until a socket connection to the requested host is established. If HTTPX...
Read more >
How can I fix ConnectTimeout exceptions from within FastAPI
I seem to be running into an issue at higher concurrency where my client.post is causing a httpx.ConnectTimeout exception.
Read more >
Connect Timeout confusion · Issue #832 · encode/httpx - GitHub
Hi! I'm quite confused about Connect Timeout. I observed that I have some applications that happens to throw a ConnectionTimeout exception ...
Read more >
How to use the httpx.AsyncClient function in httpx - Snyk
To help you get started, we've selected a few httpx.AsyncClient examples ... _make_url(station, lat, lon) try: async with httpx. ... ConnectTimeout, httpx.
Read more >
Python Examples of httpx.get - ProgramCreek.com
ConnectTimeout, httpx.ReadTimeout): raise TimeoutError(f"Timeout from {self.__class__.__name__} server") except gaierror: raise ConnectionError( f"Unable to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found