Skip to content

Intermittent "ConnectionResetError: Connection lost" error #27

Closed

Description

@simonw

Recent traceback (from my Heroku logs):

heroku[router]: at=info method=GET path="/-/auth-callback?code=e124aa75f61efd442f86" host=datasette-auth-demo.herokuapp.com request_id=834768c7-8903-4853-98c0-5bae77ffba3e fwd="148.64.98.14" dyno=web.1 connect=1ms service=93ms status=500 bytes=212 protocol=https
app[web.1]: ERROR: Exception in ASGI application
app[web.1]: Traceback (most recent call last):
app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/uvicorn/protocols/http/httptools_impl.py", line 370, in run_asgi
app[web.1]: result = await app(self.scope, self.receive, self.send)
app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/datasette_auth_github/github_auth.py", line 77, in __call__
app[web.1]: return await self.auth_callback(scope, receive, send)
app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/datasette_auth_github/github_auth.py", line 216, in auth_callback
app[web.1]: profile = (await self.github_api_client.get(profile_url)).json()
app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/http3/client.py", line 316, in get
app[web.1]: timeout=timeout,
app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/http3/client.py", line 548, in request
app[web.1]: timeout=timeout,
app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/http3/client.py", line 145, in send
app[web.1]: allow_redirects=allow_redirects,
app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/http3/client.py", line 178, in send_handling_redirects
app[web.1]: request, verify=verify, cert=cert, timeout=timeout
app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/http3/dispatch/connection_pool.py", line 121, in send
app[web.1]: raise exc
app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/http3/dispatch/connection_pool.py", line 116, in send
app[web.1]: request, verify=verify, cert=cert, timeout=timeout
app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/http3/dispatch/connection.py", line 59, in send
app[web.1]: response = await self.h11_connection.send(request, timeout=timeout)
app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/http3/dispatch/http11.py", line 49, in send
app[web.1]: await self._send_request(request, timeout)
app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/http3/dispatch/http11.py", line 83, in _send_request
app[web.1]: await self._send_event(event, timeout)
app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/http3/dispatch/http11.py", line 115, in _send_event
app[web.1]: await self.writer.write(bytes_to_send, timeout)
app[web.1]: File "/app/.heroku/python/lib/python3.6/site-packages/http3/concurrency.py", line 133, in write
app[web.1]: self.stream_writer.drain(), timeout.write_timeout
app[web.1]: File "/app/.heroku/python/lib/python3.6/asyncio/tasks.py", line 358, in wait_for
app[web.1]: return fut.result()
app[web.1]: File "/app/.heroku/python/lib/python3.6/asyncio/streams.py", line 339, in drain
app[web.1]: yield from self._protocol._drain_helper()
app[web.1]: File "/app/.heroku/python/lib/python3.6/asyncio/streams.py", line 210, in _drain_helper
app[web.1]: raise ConnectionResetError('Connection lost')
app[web.1]: ConnectionResetError: Connection lost
app[web.1]: INFO: ('10.13.156.79', 19351) - "GET /-/auth-callback HTTP/1.1" 500

Matches an existing bug report in http3 here: encode/httpx#95 - I posted a comment on there saying I'm still seeing the problem.

Activity

  1. simonw commented on Jul 7, 2019

    @simonw
    OwnerAuthor

    I currently reuse the same http3.AsyncClient() instance across multiple requests (it's a class-level constant). I'm going to try creating a new client for each request.

    class GitHubAuth:
    cookie_name = "asgi_auth"
    logout_cookie_name = "asgi_auth_logout"
    callback_path = "/-/auth-callback"
    logout_path = "/-/logout"
    # Tests can over-ride github_api_client here:
    github_api_client = http3.AsyncClient()

  2. added a commit that references this issue on Jul 7, 2019
  3. simonw commented on Jul 7, 2019

    @simonw
    OwnerAuthor

    This seams to have fixed the issue. Closing this - will re-open if it occurs again.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions