Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ValueError in version 0.11.7 #727

Closed
felipe3dfx opened this issue Jul 28, 2020 · 10 comments
Closed

ValueError in version 0.11.7 #727

felipe3dfx opened this issue Jul 28, 2020 · 10 comments

Comments

@felipe3dfx
Copy link

there are a bug in the last version.

image

Packages:

acme 1.1.0
aioredis 1.3.1
asgiref 3.2.10
async-timeout 3.0.1
attrs 19.3.0
autobahn 20.7.1
automat 20.2.0
ax3-mercadopago 0.2.6
ax3-model-extras 1.2.5
ax3-redactor 1.0.11
backcall 0.2.0
blinker 1.4
cachetools 4.1.1
certbot 0.40.0
certifi 2020.6.20
cffi 1.14.1
channels 2.4.0
channels-redis 3.0.1
chardet 3.0.4
click 7.1.2
colorama 0.4.3
command-not-found 0.3
configargparse 0.13.0
configobj 5.0.6
constantly 15.1.0
cryptography 3.0
cssselect 1.1.0
cssutils 1.0.2
daphne 2.5.0
dbus-python 1.2.16
decorator 4.4.2
defusedxml 0.6.0
distro 1.4.0
distro-info 0.23ubuntu1
django 3.0.8
django-admin-sortable 2.2.3
django-appconf 1.0.4
django-axes 5.4.1
django-compressor 2.4
django-extensions 3.0.3
django-hashid-field 3.1.3
django-ipware 3.0.0
django-redis 4.12.1
django-widget-tweaks 1.4.8
entrypoints 0.3
fail2ban 0.11.1
future 0.18.2
gdal 3.0.4
gunicorn 20.0.4
h11 0.9.0
hashids 1.3.1
hiredis 1.1.0
httplib2 0.14.0
httptools 0.1.1
huey 2.2.0
hyperlink 19.0.0
idna 2.10
incremental 17.5.0
iotop 0.6
ipython 7.16.1
ipython-genutils 0.2.0
jedi 0.17.2
josepy 1.2.0
keyring 18.0.1
language-selector 0.1
launchpadlib 1.10.13
lazr.restfulclient 0.14.2
lazr.uri 1.0.3
linecache2 1.0.0
lxml 4.5.2
mock 3.0.5
msgpack 1.0.0
netifaces 0.10.4
numpy 1.17.4
oauthlib 3.1.0
parsedatetime 2.4
parso 0.7.1
pbr 5.4.5
pexpect 4.8.0
pickleshare 0.7.5
pillow 7.2.0
pip 20.1.1
pip-tools 5.2.1
premailer 3.7.0
prompt-toolkit 3.0.5
psycopg2 2.8.4
psycopg2-binary 2.8.5
ptyprocess 0.6.0
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycparser 2.20
pygments 2.6.1
pygobject 3.36.0
pyhamcrest 2.0.2
pyicu 2.4.2
pyinotify 0.9.6
pyjwt 1.7.1
pymacaroons 0.13.0
pymercadopago 0.3.0
pynacl 1.3.0
pyopenssl 19.1.0
pyrfc3339 1.1
python-apt 2.0.0+ubuntu0.20.4.1
python-dateutil 2.8.1
python-debian 0.1.36ubuntu1
python-magic 0.4.18
python-resize-image 1.1.19
python3-openid 3.2.0
pytz 2020.1
pyyaml 5.3.1
rcssmin 1.0.6
redis 3.5.3
requests 2.24.0
requests-oauthlib 1.3.0
requests-toolbelt 0.8.0
requests-unixsocket 0.2.0
rjsmin 1.1.0
secretstorage 2.3.1
sentry-sdk 0.16.2
service-identity 18.1.0
setuptools 45.2.0
simplejson 3.16.0
six 1.15.0
social-auth-app-django 4.0.0
social-auth-core 3.3.3
sqlparse 0.3.1
ssh-import-id 5.10
systemd-python 234
testresources 2.0.0
traceback2 1.4.0
traitlets 4.3.3
twisted 20.3.0
txaio 20.4.1
ubuntu-advantage-tools 20.3
ufw 0.36
unattended-upgrades 0.1
unittest2 1.1.0
urllib3 1.25.10
uvicorn 0.11.7
uvloop 0.14.0
wadllib 1.3.3
wcwidth 0.2.5
websockets 8.1
wheel 0.34.2
zope.component 4.3.0
zope.event 4.4
zope.hookable 5.0.0
zope.interface 5.1.0

Any ideas?

@seb-b
Copy link

seb-b commented Jul 28, 2020

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' 

@euri10
Copy link
Member

euri10 commented Jul 29, 2020 via email

@euri10
Copy link
Member

euri10 commented Jul 29, 2020

I suspect it's this commit which introduced the bug a796e1d
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

@tomchristie
Copy link
Member

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.

@tomchristie
Copy link
Member

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.

@euri10
Copy link
Member

euri10 commented Jul 29, 2020

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.

@felipe3dfx
Copy link
Author

felipe3dfx commented Jul 29, 2020

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;
}

@stefanw
Copy link

stefanw commented Jul 30, 2020

All deployments using unix sockets are broken due to a796e1d.

It's quite unfortunate that this commit – apparently unrelated to the security fixes – made it into the 0.11.7 security release.

@bukowa
Copy link

bukowa commented Jul 30, 2020

#733

@euri10
Copy link
Member

euri10 commented Jul 31, 2020

fixed in #729

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants