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

Traceback: OSError: [Errno 107] Transport endpoint is not connected #525

Closed
juergenc opened this issue Dec 13, 2019 · 4 comments
Closed

Comments

@juergenc
Copy link

I have Python 3 virtualenv where uvicorn and fastAPI is running inside. Every day an internal security scanner checks our hosts via network scanning for open TCP ports. In case it finds out it is a web server socket, the security scanner sends all kinds of GET and POST requests with spurious URL strings trying to find a vulnerability. For some HTTP (not HTTPS!) request for which I don't know neither the method nor the URL (it looks like the scanner doesn't send any, just open the TCP port and closes it immediately again, maybe just a SYN packet?), we have a Python Traceback, see below.

Setup

Python

$ python -V
Python 3.7.3

Virtualenv

$ pip list
Package         Version
--------------- -------
Click           7.0    
dnspython       1.16.0 
email-validator 1.0.4  
fastapi         0.44.0 
h11             0.8.1  
httptools       0.0.13 
idna            2.8    
multi-key-dict  2.0.3  
pip             18.1   
pkg-resources   0.0.0  
psycopg2        2.8.4  
pydantic        1.2    
setuptools      40.8.0 
SQLAlchemy      1.3.10 
starlette       0.12.9 
uvicorn         0.10.8 
uvloop          0.14.0 
websockets      8.0.2  
wheel           0.33.6

Uvicorn Python Traceback

Dec 13 09:10:15 mcf-elk01 python3[1975]: ERROR:    Exception in callback UVTransport._call_connection_made
Dec 13 09:10:15 mcf-elk01 python3[1975]: handle: <Handle UVTransport._call_connection_made>
Dec 13 09:10:15 mcf-elk01 python3[1975]: Traceback (most recent call last):
Dec 13 09:10:15 mcf-elk01 python3[1975]:   File "uvloop/cbhandles.pyx", line 73, in uvloop.loop.Handle._run
Dec 13 09:10:15 mcf-elk01 python3[1975]:   File "uvloop/handles/tcp.pyx", line 153, in uvloop.loop.TCPTransport._call_connection_made
Dec 13 09:10:15 mcf-elk01 python3[1975]:   File "uvloop/handles/basetransport.pyx", line 134, in uvloop.loop.UVBaseTransport._call_connection_made
Dec 13 09:10:15 mcf-elk01 python3[1975]:   File "uvloop/handles/basetransport.pyx", line 131, in uvloop.loop.UVBaseTransport._call_connection_made
Dec 13 09:10:15 mcf-elk01 python3[1975]:   File "/home/jk/ixapi/lib/python3.7/site-packages/uvicorn/protocols/http/httptools_impl.py", line 129, in connection_made
Dec 13 09:10:15 mcf-elk01 python3[1975]:     self.client = get_remote_addr(transport)
Dec 13 09:10:15 mcf-elk01 python3[1975]:   File "/home/jk/ixapi/lib/python3.7/site-packages/uvicorn/protocols/utils.py", line 7, in get_remote_addr
Dec 13 09:10:15 mcf-elk01 python3[1975]:     info = socket_info.getpeername()
Dec 13 09:10:15 mcf-elk01 python3[1975]:   File "uvloop/pseudosock.pyx", line 104, in uvloop.loop.PseudoSocket.getpeername
Dec 13 09:10:15 mcf-elk01 python3[1975]: OSError: [Errno 107] Transport endpoint is not connected
@tomchristie
Copy link
Member

May be resolved by #495

We're probably due a new release.

@kevsersrca
Copy link

kevsersrca commented Jan 16, 2020

I get the same error since two days. API uses Fastapi and only responds to the http request.

Python Version: 3.6.8
Pip Version: 19.3.1
Uvicorn: Running uvicorn 0.11.1 with CPython 3.6.8 on Linux

Command:
uvicorn main:app --host 0.0.0.0 --port 80

Error:

ERROR: 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/tcp.pyx", line 153, in uvloop.loop.TCPTransport._call_connection_made
  File "uvloop/handles/basetransport.pyx", line 130, in uvloop.loop.UVBaseTransport._call_connection_made
  File "uvloop/handles/basetransport.pyx", line 127, in uvloop.loop.UVBaseTransport._call_connection_made
  File "/usr/local/lib/python3.6/dist-packages/uvicorn/protocols/http/httptools_impl.py", line 125, in connection_made
    self.client = get_remote_addr(transport)
  File "/usr/local/lib/python3.6/dist-packages/uvicorn/protocols/utils.py", line 7, in get_remote_addr
    info = socket_info.getpeername()
  File "uvloop/pseudosock.pyx", line 104, in uvloop.loop.PseudoSocket.getpeername
OSError: [Errno 107] Transport endpoint is not connected
ERROR: 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/tcp.pyx", line 153, in uvloop.loop.TCPTransport._call_connection_made
  File "uvloop/handles/basetransport.pyx", line 130, in uvloop.loop.UVBaseTransport._call_connection_made
  File "uvloop/handles/basetransport.pyx", line 127, in uvloop.loop.UVBaseTransport._call_connection_made
  File "/usr/local/lib/python3.6/dist-packages/uvicorn/protocols/http/httptools_impl.py", line 125, in connection_made
    self.client = get_remote_addr(transport)
  File "/usr/local/lib/python3.6/dist-packages/uvicorn/protocols/utils.py", line 7, in get_remote_addr
    info = socket_info.getpeername()
  File "uvloop/pseudosock.pyx", line 104, in uvloop.loop.PseudoSocket.getpeername
OSError: [Errno 107] Transport endpoint is not connected

Api responding requests but i get this error periodically

@tomchristie

@euri10
Copy link
Member

euri10 commented Dec 28, 2020

I'm closing this as it seems stale, feel free to add more information especially regarding the requests that triggered this and we will reopen !

@euri10 euri10 closed this as completed Dec 28, 2020
@ferdavs
Copy link

ferdavs commented Mar 24, 2021

This is happening when I set port=0 (random port) and it is working on 0.11.8

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

5 participants