You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
🐞 Describe the bug
A ConnectionRefusedError using UnixConnector results in an error message such as this:
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host host:80 ssl:default [Connection refused]
The error message specifies the host/port of the connection. However, for Unix sockets, the host/port are not useful. They're still provided as part of the HTTP request, but they do not define the connection from client to server.
For unix sockets, ideally the error message would include the socket path on disk instead.
💡 To Reproduce
Run this code:
Note: don't create /tmp/server.sock to get a Connection Refused.
import aiohttp
import asyncio
async def main():
async with aiohttp.ClientSession(
connector=aiohttp.UnixConnector(path='/tmp/server.sock'),
) as session:
r = await session.get('http://host/')
print("Status:", r.status)
print("Text:")
print((await r.text()).strip())
asyncio.get_event_loop().run_until_complete(main())
💡 Expected behavior
Ideally, the exception would include the socket path on disk, which (for Unix sockets) is the primary way of identifying the connection, not host/port.
📋 Logs/tracebacks
Output of the sample script I pasted above:
Traceback (most recent call last):
File "/home/zeal/dev/aiohttp/venv/lib/python3.8/site-packages/aiohttp-4.0.0a1-py3.8-linux-x86_64.egg/aiohttp/connector.py", line 1112, in _create_connection
_, proto =awaitself._loop.create_unix_connection(
File "/usr/lib/python3.8/asyncio/unix_events.py", line 244, in create_unix_connectionawaitself.sock_connect(sock, path)
File "/usr/lib/python3.8/asyncio/selector_events.py", line 494, in sock_connectreturnawait fut
File "/usr/lib/python3.8/asyncio/selector_events.py", line 499, in _sock_connect
sock.connect(address)
ConnectionRefusedError: [Errno 111] Connection refused
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "client.py", line 15, in <module>
asyncio.get_event_loop().run_until_complete(main())
File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_completereturn future.result()
File "client.py", line 9, in main
r =await session.get('http://host/')
File "/home/zeal/dev/aiohttp/venv/lib/python3.8/site-packages/aiohttp-4.0.0a1-py3.8-linux-x86_64.egg/aiohttp/client.py", line 446, in _request
conn =awaitself._connector.connect(
File "/home/zeal/dev/aiohttp/venv/lib/python3.8/site-packages/aiohttp-4.0.0a1-py3.8-linux-x86_64.egg/aiohttp/connector.py", line 506, in connect
proto =awaitself._create_connection(req, traces, timeout)
File "/home/zeal/dev/aiohttp/venv/lib/python3.8/site-packages/aiohttp-4.0.0a1-py3.8-linux-x86_64.egg/aiohttp/connector.py", line 1115, in _create_connectionraise ClientConnectorError(req.connection_key, exc) from exc
aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host host:80 ssl:default [Connection refused]
📋 Your version of the Python
$ python --versionPython 3.8.5
📋 Your version of the aiohttp/yarl/multidict distributions
Installed from source at commit 90acab1, so the versions below are not correct, but attaching them anyway.
🐞 Describe the bug
A ConnectionRefusedError using UnixConnector results in an error message such as this:
The error message specifies the host/port of the connection. However, for Unix sockets, the host/port are not useful. They're still provided as part of the HTTP request, but they do not define the connection from client to server.
For unix sockets, ideally the error message would include the socket path on disk instead.
💡 To Reproduce
Run this code:
Note: don't create
/tmp/server.sock
to get a Connection Refused.💡 Expected behavior
Ideally, the exception would include the socket path on disk, which (for Unix sockets) is the primary way of identifying the connection, not host/port.
📋 Logs/tracebacks
Output of the sample script I pasted above:
📋 Your version of the Python
📋 Your version of the aiohttp/yarl/multidict distributions
Installed from source at commit 90acab1, so the versions below are not correct, but attaching them anyway.
📋 Additional context
None
The text was updated successfully, but these errors were encountered: