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

transport.get_extra_info("socket").getpeername() returns a socket with a raddr of (0,b'\x00\x00\x00\x00') ) #600

Closed
George-Miao opened this issue Mar 23, 2020 · 8 comments

Comments

@George-Miao
Copy link

George-Miao commented Mar 23, 2020

traceback:
ERROR: Exception in callback H11Protocol.connection_made(<_SelectorSoc...e, bufsize=0>>) handle: <Handle H11Protocol.connection_made(<_SelectorSoc...e, bufsize=0>>)> Traceback (most recent call last): File "D:\Work\env\Python37\lib\asyncio\events.py", line 88, in _run self._context.run(self._callback, *self._args) File "D:\Work\env\Daims_Fastapi\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 125, in connection_made self.client = get_remote_addr(transport) File "D:\Work\env\Daims_Fastapi\lib\site-packages\uvicorn\protocols\utils.py", line 20, in get_remote_addr return (str(info[0]), int(info[1])) ValueError: invalid literal for int() with base 10: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

@euri10
Copy link
Member

euri10 commented Mar 23, 2020

what command did you use ?
what part of the code triggers this ?
there's not enough information as it stands

@4mYHime
Copy link

4mYHime commented Apr 19, 2020

got the same problem.

ERROR[0m: Exception in callback H11Protocol.connection_made(<_SelectorSoc...e, bufsize=0>>) handle: <Handle H11Protocol.connection_made(<_SelectorSoc...e, bufsize=0>>)> Traceback (most recent call last): File "c:\users\4myhime\anaconda3\envs\elearning\lib\asyncio\events.py", line 88, in _run self._context.run(self._callback, *self._args) File "c:\users\4myhime\anaconda3\envs\elearning\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 125, in connection_made self.client = get_remote_addr(transport) File "c:\users\4myhime\anaconda3\envs\elearning\lib\site-packages\uvicorn\protocols\utils.py", line 18, in get_remote_addr return (str(info[0]), int(info[1])) ValueError: invalid literal for int() with base 10: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

i just run it on the local ENV with command uvicorn run:app --reload --host 0.0.0.0 ,
IT WORKS with no error.

The following operation will cause an error:

  • Open the redoc/docs API documentation for the first time.
  • Try to connect web socket that i expose.

Thanks for any help

@euri10
Copy link
Member

euri10 commented Apr 19, 2020

The following operation will cause an error:

  • Open the redoc/docs API documentation for the first time.
  • Try to connect web socket that i expose.

Thanks for any help

it's hard to tell without seeing any part of your code that triggers this error, thanks for writing a minimal example that causes the exception
what uvicorn version are you using by the way ?

@4mYHime
Copy link

4mYHime commented Apr 19, 2020

it's hard to tell without seeing any part of your code that triggers this error, thanks for writing a minimal example that causes the exception
what uvicorn version are you using by the way ?

thanks for comment.
uvicorn version: 0.11.3

In the past two hours, i try to find reason that cause the error,what is depressing that i didn't.
And i restart network ,turn off proxy program, there's no error any more,it's realy confusing.
maybe the problem is the bad network and dns cache.
i'll submit detailed information in the next time,thanks again for the advice

@yangpengcheng
Copy link

i got the same problem:

main.py
`from fastapi import FastAPI

app = FastAPI()

@app.get('/')
async def root():
return {'message': 'hello world'}`

Related dependencies:
Package Version


click 7.1.2
fastapi 0.58.0
h11 0.9.0
pip 19.0.3
pydantic 1.5.1
setuptools 40.8.0
starlette 0.13.4
uvicorn 0.11.5
websockets 8.1

Execute the following command in the command line:
uvicorn main:app --reload

and Open the following address in the browser
http://127.0.0.1:8000/

then i got the problem

@euri10
Copy link
Member

euri10 commented Sep 29, 2020

I'm going to close this as stale @GeorgeMiao219 but feel free to reopen
that feels very similar to #727 which #729 fixed though.

@yykrlc
Copy link

yykrlc commented Nov 1, 2020

  File "D:\code\websocker_fastapi_demo\venv\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 291, in handle_upgrade
    protocol.connection_made(self.transport)
  File "D:\code\websocker_fastapi_demo\venv\lib\site-packages\uvicorn\protocols\websockets\websockets_impl.py", line 63, in connection_made
    self.client = get_remote_addr(transport)
  File "D:\code\websocker_fastapi_demo\venv\lib\site-packages\uvicorn\protocols\utils.py", line 9, in get_remote_addr
    return (str(info[0]), int(info[1])) if isinstance(info, tuple) else None
ValueError: invalid literal for int() with base 10: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
and 
INFO:     Uvicorn running on http://0.0.0.0:8001 (Press CTRL+C to quit)
INFO:     None - "WebSocket /ws" [accepted]
---transport---: <_SelectorSocketTransport fd=780 read=idle write=<idle, bufsize=0>>
---info--- (0, b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
---info--isinstance- True
---transport---: <_SelectorSocketTransport fd=780 read=polling write=<idle, bufsize=0>>
---info--- (0, b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')
---info--isinstance- True

old win10

PyYAML 5.3.1 5.3.1
click 7.1.2 7.1.2
colorama 0.4.4 0.4.4
fastapi 0.61.1 0.61.1
h11 0.11.0 0.11.0
pip 20.2.4 20.3b1
pydantic 1.7.2 1.7.2
python-dotenv 0.15.0 0.15.0
setuptools 50.3.2 50.3.2
starlette 0.13.6 0.13.8
unicorn 1.0.2 1.0.2
uvicorn 0.12.2 0.12.2
watchgod 0.6 0.6
websockets 8.1 8.1

@cih1996
Copy link

cih1996 commented Oct 5, 2021

我也出现了这个问题,刚开始很正常,突然重新运行就出现的,并且还无法定位到我们编写的代码错误,直接定位到了内部文件报错。经过调试输出发现raddr都是00000所导致的转换报错,尝试重新安装也没用,同样把最新的代码放到另一台电脑上可以使用(并且同一个局域网)
<asyncio.TransportSocket fd=960, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('127.0.0.1', 8000), raddr=(0, b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')> Fatal error in server handler protocol: <uvicorn.protocols.http.h11_impl.H11Protocol object at 0x043ADA18> transport: <_SelectorSocketTransport fd=960 read=polling write=<idle, bufsize=0>> Traceback (most recent call last): File "c:\users\85913\appdata\local\programs\python\python39-32\lib\site-packages\uvicorn\server.py", line 107, in handler await handle_http( File "c:\users\85913\appdata\local\programs\python\python39-32\lib\site-packages\uvicorn\_handlers\http.py", line 75, in handle_http protocol.connection_made(transport) File "c:\users\85913\appdata\local\programs\python\python39-32\lib\site-packages\uvicorn\protocols\http\h11_impl.py", line 85, in connection_made self.client = get_remote_addr(transport) File "c:\users\85913\appdata\local\programs\python\python39-32\lib\site-packages\uvicorn\protocols\utils.py", line 14, in get_remote_addr return (str(info[0]), int(info[1])) if isinstance(info, tuple) else None ValueError: invalid literal for int() with base 10: b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' INFO: - "GET /index HTTP/1.1" 200 OK

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