irmen / Pyro5

Pyro 5 - Python remote objects
https://pyro5.readthedocs.io
MIT License
303 stars 36 forks source link

Warehouse tutorial Phase 2: [WinError 10049] The requested address is not valid in its context #70

Closed yannbouteiller closed 1 year ago

yannbouteiller commented 1 year ago

Hello,

I am trying to use Pyro as a hopefully safe and robust way of transferring python objects over the Internet.

Thus far I am following the tutorial, but I get a connection error when running the "Phase 2" of visit.py (Windows 11):

warehouse.py:

(pyro) C:\Users\yannb\Desktop\pyro tuto>python warehouse.py
Object <class '__main__.Warehouse'>:
    uri = PYRO:example.warehouse@0.0.0.0:53646
Pyro daemon running.

visit.py:

C:\Users\yannb\anaconda3\envs\pyro\python.exe "C:\Users\yannb\Desktop\pyro tuto\visit.py" 
Enter the uri of the warehouse: PYRO:example.warehouse@0.0.0.0:53646
This is Janet.
Traceback (most recent call last):
  File "C:\Users\yannb\anaconda3\envs\pyro\lib\site-packages\Pyro5\client.py", line 278, in connect_and_handshake
    sock = socketutil.create_socket(connect=connect_location,
  File "C:\Users\yannb\anaconda3\envs\pyro\lib\site-packages\Pyro5\socketutil.py", line 283, in create_socket
    sock.connect(connect)
OSError: [WinError 10049] The requested address is not valid in its context

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\yannb\Desktop\pyro tuto\visit.py", line 11, in <module>
    janet.visit(warehouse)
  File "C:\Users\yannb\Desktop\pyro tuto\person.py", line 14, in visit
    self.deposit(warehouse)
  File "C:\Users\yannb\Desktop\pyro tuto\person.py", line 19, in deposit
    print("The warehouse contains:", warehouse.list_contents())
  File "C:\Users\yannb\anaconda3\envs\pyro\lib\site-packages\Pyro5\client.py", line 92, in __getattr__
    self._pyroGetMetadata()
  File "C:\Users\yannb\anaconda3\envs\pyro\lib\site-packages\Pyro5\client.py", line 358, in _pyroGetMetadata
    self.__pyroCreateConnection()
  File "C:\Users\yannb\anaconda3\envs\pyro\lib\site-packages\Pyro5\client.py", line 342, in __pyroCreateConnection
    connect_and_handshake(conn)
  File "C:\Users\yannb\anaconda3\envs\pyro\lib\site-packages\Pyro5\client.py", line 304, in connect_and_handshake
    raise errors.CommunicationError(err) from x
Pyro5.errors.CommunicationError: cannot connect to ('0.0.0.0', 53646): [WinError 10049] The requested address is not valid in its context

Process finished with exit code 1
yannbouteiller commented 1 year ago

PS: same issue with Phase 3

irmen commented 1 year ago

This is some windows weirdness with the default IP address it seems. (the problem doesn't occur on Linux for example).

Anyway for now try editing warehouse.py : add an host=None or host='localhost' argument to the serve(....) call at the bottom. Restart it and the URI that is printed should no longer contain 0.0.0.0

Maybe I can change this a bit for the next release

irmen commented 1 year ago

I changed something in the serve() call in Pyro 5.14 that was just released, this should take care of this issue on windows.