mautrix / googlechat

A Matrix-Google Chat puppeting bridge
https://matrix.to/#/#googlechat:maunium.net
GNU Affero General Public License v3.0
111 stars 30 forks source link

Timeout when submitting oauth_code #49

Closed meyerrj closed 3 years ago

meyerrj commented 3 years ago

When trying to authenticate using the current docker image (as of this submission), I experience a long delay when submitting the oauth_code value, and ultimately a failure.

After this error the docker image becomes unresponsive and has to be restarted.

I should note that I am using a Google account that is a Google Workspace (custom domain).

Docker log details:

[2021-09-18 04:21:24,037] [INFO@aiohttp.access] 172.18.0.3 [18/Sep/2021:04:21:24 +0000] "PUT /transactions/29?access_token=TOKEN_REMOVED HTTP/1.1" 200 158 "-" "Synapse/1.42.0"
[2021-09-18 04:21:25,923] [INFO@aiohttp.access] 172.18.0.1 [18/Sep/2021:04:21:25 +0000] "POST /login/api/verify HTTP/1.1" 200 194 "https://matrix.domain.tld/mautrix-googlechat/login/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.41 Safari/537.36 Edg/94.0.992.19"
[2021-09-18 04:21:27,682] [INFO@aiohttp.access] 172.18.0.1 [18/Sep/2021:04:21:27 +0000] "POST /login/api/start HTTP/1.1" 200 470 "https://matrix.domain.tld/mautrix-googlechat/login/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.41 Safari/537.36 Edg/94.0.992.19"
[2021-09-18 04:26:59,387] [ERROR@mau.user.@user:domain.tld] Exception in connection
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/aiohttp/client.py", line 520, in _request
    conn = await self._connector.connect(
  File "/usr/lib/python3.9/site-packages/aiohttp/connector.py", line 535, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "/usr/lib/python3.9/site-packages/aiohttp/connector.py", line 892, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "/usr/lib/python3.9/site-packages/aiohttp/connector.py", line 1020, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "/usr/lib/python3.9/site-packages/aiohttp/connector.py", line 969, in _wrap_create_connection
    return await self._loop.create_connection(*args, **kwargs)  # type: ignore  # noqa
  File "/usr/lib/python3.9/asyncio/base_events.py", line 1041, in create_connection
    sock = await self._connect_sock(
  File "/usr/lib/python3.9/asyncio/base_events.py", line 955, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/lib/python3.9/asyncio/selector_events.py", line 502, in sock_connect
    return await fut
asyncio.exceptions.CancelledError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/aiohttp/client.py", line 520, in _request
    conn = await self._connector.connect(
  File "/usr/lib/python3.9/site-packages/async_timeout/__init__.py", line 45, in __exit__
    self._do_exit(exc_type)
  File "/usr/lib/python3.9/site-packages/async_timeout/__init__.py", line 92, in _do_exit
    raise asyncio.TimeoutError
asyncio.exceptions.TimeoutError

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/mautrix_googlechat/user.py", line 216, in start
    await self.client.connect()
  File "/usr/lib/python3.9/site-packages/hangups/client.py", line 150, in connect
    await self._listen_future
  File "/usr/lib/python3.9/site-packages/hangups/channel.py", line 179, in listen
    self._csessionid_param = await self._register()
  File "/usr/lib/python3.9/site-packages/hangups/channel.py", line 234, in _register
    res = await self._session.fetch_raw('POST', CHANNEL_URL_BASE + 'register', headers=headers)
  File "/usr/lib/python3.9/site-packages/hangups/http_utils.py", line 132, in fetch_raw
    return await resp
  File "/usr/lib/python3.9/site-packages/aiohttp/client.py", line 524, in _request
    raise ServerTimeoutError(
aiohttp.client_exceptions.ServerTimeoutError: Connection timeout to host https://chat.google.com/webchannel/register

Error log entry from nginx reverse proxy:

2021/09/18 04:32:07 [error] 10#10: *1848 upstream timed out (110: Operation timed out) while reading response header from upstream, client: address-removed, server: matrix.domain.tld, request: "POST /mautrix-googlechat/login/api/authorization HTTP/2.0", upstream: "http://address-removed:29320/login/api/authorization", host: "matrix.domain.tld", referrer: "https://matrix.domain.tld/mautrix-googlechat/login/"
meyerrj commented 3 years ago

Update: The issue turned out to be a problem with the IPv6 configuration in my network.

Some required routes for docker were nuked after a power outage, and had to be rebuilt. It did not appear to try and fallback to an IPv4 connection and instead was hanging on the IPv6 address attempt.