Describe the bug
- I am unable to specify a HTTP proxy via the
Settings
mattermostautodriver.websocket uses aiohttp, which seems to ignore a proxy set through the environment variables
- If proxy is manually passed directly to the Mattermost driver, everything is fine (but that seems to be rather a workaround!)
How To Reproduce
bot = Bot(
settings=Settings(
MATTERMOST_URL = "https://...",
MATTERMOST_PORT = 443,
BOT_TOKEN = "...",
BOT_TEAM = "...",
SSL_VERIFY = True,
DEBUG=True
),
plugins=[],
)
Bot initializes correctly, uses HTTP proxy set in ENV variables:
[01/10/2025 08:51:23][httpcore.connection][DEBUG] connect_tcp.started host='<REDACTED_PROXY_HOST>' port=8080 local_address=None timeout=None socket_options=None
[01/10/2025 08:51:23][httpcore.connection][DEBUG] connect_tcp.complete return_value=<httpcore._backends.sync.SyncStream object at 0x7f5eabecaff0>
[01/10/2025 08:51:23][httpcore.http11][DEBUG] send_request_headers.started request=<Request [b'CONNECT']>
[01/10/2025 08:51:23][httpcore.http11][DEBUG] send_request_headers.complete
[01/10/2025 08:51:23][httpcore.http11][DEBUG] send_request_body.started request=<Request [b'CONNECT']>
[01/10/2025 08:51:23][httpcore.http11][DEBUG] send_request_body.complete
[01/10/2025 08:51:23][httpcore.http11][DEBUG] receive_response_headers.started request=<Request [b'CONNECT']>
[01/10/2025 08:51:23][httpcore.http11][DEBUG] receive_response_headers.complete return_value=(b'HTTP/1.0', 200, b'Connection Established', [])
Then call:
Which causes:
[01/10/2025 08:51:23][mattermostautodriver.websocket][ERROR] Failed to establish websocket connection: <class 'aiohttp.client_exceptions.ClientConnectorDNSError'> thrown
Traceback (most recent call last):
File "/home/fabian/.cache/pypoetry/virtualenvs/rapid-xKExur4M-py3.12/lib/python3.12/site-packages/aiohttp/connector.py", line 1351, in _create_direct_connection
hosts = await self._resolve_host(host, port, traces=traces)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/fabian/.cache/pypoetry/virtualenvs/rapid-xKExur4M-py3.12/lib/python3.12/site-packages/aiohttp/connector.py", line 995, in _resolve_host
return await asyncio.shield(resolved_host_task)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/fabian/.cache/pypoetry/virtualenvs/rapid-xKExur4M-py3.12/lib/python3.12/site-packages/aiohttp/connector.py", line 1026, in _resolve_host_with_throttle
addrs = await self._resolver.resolve(host, port, family=self._family)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/fabian/.cache/pypoetry/virtualenvs/rapid-xKExur4M-py3.12/lib/python3.12/site-packages/aiohttp/resolver.py", line 36, in resolve
infos = await self._loop.getaddrinfo(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/asyncio/base_events.py", line 901, in getaddrinfo
return await self.run_in_executor(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.12/socket.py", line 963, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
socket.gaierror: [Errno -3] Temporary failure in name resolution
If I add the following before the bot.run() call, then everything works fine:
bot.driver.options["proxy"] = "http://...."
Expected behavior
- mmpy_bot should read the proxy from the environment variables and pass it to the Mattermost driver
- Or even better: Offer to configure the proxy manually via the
Settings
Operating Environment (please complete the following information):
- mmpy_bot Version: 2.2.0
- mattermostdriver/mattermostautodriver Version: 1.3.0
- Mattermost Server Version: 10.3.1
- Python Version: 3.12
- OS: Linux
Describe the bug
Settingsmattermostautodriver.websocketusesaiohttp, which seems to ignore a proxy set through the environment variablesHow To Reproduce
Bot initializes correctly, uses HTTP proxy set in ENV variables:
Then call:
Which causes:
If I add the following before the
bot.run()call, then everything works fine:Expected behavior
SettingsOperating Environment (please complete the following information):