Closed felipe3dfx closed 4 years ago
I'm hitting the same problem, had to downgrade to 0.11.6 to fix. Using with django + channels
Exception in callback UVTransport._call_connection_made
handle: <Handle UVTransport._call_connection_made>
Traceback (most recent call last):
File "uvloop/cbhandles.pyx", line 73, in uvloop.loop.Handle._run
File "uvloop/handles/basetransport.pyx", line 134, in uvloop.loop.UVBaseTransport._call_connection_made
File "uvloop/handles/basetransport.pyx", line 131, in uvloop.loop.UVBaseTransport._call_connection_made
File "/usr/lib/python3.8/site-packages/uvicorn/protocols/http/httptools_impl.py", line 132, in connection_made
self.server = get_local_addr(transport)
File "/usr/lib/python3.8/site-packages/uvicorn/protocols/utils.py", line 39, in get_local_addr
return (str(info[0]), int(info[1]))
ValueError: invalid literal for int() with base 10: 't'
With what command do you run uvicorn please ?
On Wed, Jul 29, 2020, 1:40 AM seb-b notifications@github.com wrote:
I'm hitting the same problem, had to downgrade to 0.11.6 to fix
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/encode/uvicorn/issues/727#issuecomment-665348840, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAINSPTZLTCYERDLHUOVISTR55OX3ANCNFSM4PK63PNQ .
I suspect it's this commit which introduced the bug a796e1d4418e8eb917a7856b8530427ef847236c Question is how you run your stack, seems like you have gunicorn but I could not reproduce locally just with it, is it behind a reverse proxy ? A more detailed way to reproduce would be useful. Thanks
I guess we might want to catch the ValueError there and return None
, tho it'd be useful to have a better idea exactly what values socket_info.family
might return, first.
Okay, so given this... https://docs.python.org/3/library/socket.html
We're handling AF_INET
correctly as (host, port)
.
We're handling AF_INET6
, correctly as (host, port, _, _)
We're failing to handle AF_UNIX
which returns the address as a string. The info variable is a string in this case, and we're using info[0]
and info[1]
and extracting single characters.
also this may be relevant from the gunicorn docs:
It is also worth noting that the REMOTE_ADDR will be completely empty if you bind Gunicorn to a UNIX socket and not a TCP host:port tuple.
also this may be relevant from the gunicorn docs:
It is also worth noting that the REMOTE_ADDR will be completely empty if you bind Gunicorn to a UNIX socket and not a TCP host:port tuple.
This seem to be the problem, I have gunicorn with socket as systemd service and nginx.
gunicorn.conf
d /run/gunicorn 0755 deploy deploy -
gunicorn.service
[Unit]
Description=Gunicorn service
BindsTo=gunicorn.socket redis-server.service postgresql.service
After=network.target gunicorn.socket redis-server.service postgresql.service
[Service]
# Base configuration from https://docs.gunicorn.org/en/stable/deploy.html#systemd
Type=notify
User=deploy
Group=deploy
RuntimeDirectory=gunicorn
WorkingDirectory=/any-path/
ExecStart=/home/deploy/.local/bin/gunicorn app.asgi:application --worker-class uvicorn.workers.UvicornWorker --bind unix:/run/gunicorn.sock --workers {{ GUNICORN_WORKERS }}
ExecReload=/bin/kill -s HUP $MAINPID
PrivateTmp=true
# Stop the service first using SIGTEM wait 5 seconds and then SIGKILL
KillMode=mixed
TimeoutStopSec=5
# Restart when fails, try every 5 seconds, forever
Restart=always
RestartSec=5
StartLimitInterval=0
[Install]
WantedBy=multi-user.target
gunicorn.socket
[Unit]
Description=gunicorn socket
[Socket]
ListenStream=/run/gunicorn.sock
[Install]
WantedBy=sockets.target
nginx site configuration
upstream app_server {
server unix:/run/gunicorn.sock fail_timeout=0;
}
All deployments using unix sockets are broken due to a796e1d4418e8eb917a7856b8530427ef847236c.
It's quite unfortunate that this commit – apparently unrelated to the security fixes – made it into the 0.11.7 security release.
there are a bug in the last version.
Packages:
Any ideas?