OpenMined / PySyft

Perform data science on data that remains in someone else's server
https://www.openmined.org/
Apache License 2.0
9.54k stars 1.99k forks source link

gaierror: [Errno 8] in Federated Recurrent Neural Network.ipynb #2685

Closed ZhechunZhou closed 4 years ago

ZhechunZhou commented 5 years ago

Hi I was trying to use raspberry pis to do federated machine learning I run python3 run_websocket_server.py --port 8778 --id bob --host on each pi and Federated Recurrent Neural Network.ipynb on my laptop

In 3. Step: Model - Recurrent Neural Network

kwargs_websocket_alice = {"host": "<ip of raspberry pi>", "hook": hook}
alice = WebsocketClientWorker(id="alice", port=8777, **kwargs_websocket_alice)

raise an Error gaierror: [Errno 8] nodename nor servname provided, or not known WebSocketAddressException: [Errno 8] nodename nor servname provided, or not known

---------------------------------------------------------------------------
gaierror                                  Traceback (most recent call last)
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/websocket/_http.py in _get_addrinfo_list(hostname, port, is_secure, proxy)
    142             addrinfo_list = socket.getaddrinfo(
--> 143                 hostname, port, 0, 0, socket.SOL_TCP)
    144             return addrinfo_list, False, None

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/socket.py in getaddrinfo(host, port, family, type, proto, flags)
    747     addrlist = []
--> 748     for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
    749         af, socktype, proto, canonname, sa = res

gaierror: [Errno 8] nodename nor servname provided, or not known

During handling of the above exception, another exception occurred:

WebSocketAddressException                 Traceback (most recent call last)
<ipython-input-37-90c114f5a070> in <module>
     10 hook = sy.TorchHook(torch)  # <-- NEW: hook PyTorch ie add extra
     11 kwargs_websocket_alice = {"host": "192.168.137.95", "hook": hook}
---> 12 alice = WebsocketClientWorker(id="alice", port=8777, **kwargs_websocket_alice)
     13 kwargs_websocket_bob = {"host": "192.168.137.212", "hook": hook}
     14 bob = WebsocketClientWorker(id="bob", port=8778, **kwargs_websocket_bob)

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/syft/workers/websocket_client.py in __init__(self, hook, host, port, secure, id, is_client_worker, log_msgs, verbose, data)
     48         self.secure = secure
     49         self.ws = None
---> 50         self.connect()
     51 
     52     @property

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/syft/workers/websocket_client.py in connect(self)
     60             args["sslopt"] = {"cert_reqs": ssl.CERT_NONE}
     61 
---> 62         self.ws = websocket.create_connection(**args)
     63 
     64     def close(self):

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/websocket/_core.py in create_connection(url, timeout, class_, **options)
    512                      skip_utf8_validation=skip_utf8_validation, **options)
    513     websock.settimeout(timeout if timeout is not None else getdefaulttimeout())
--> 514     websock.connect(url, **options)
    515     return websock

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/websocket/_core.py in connect(self, url, **options)
    221         self.sock_opt.timeout = options.get('timeout', self.sock_opt.timeout)
    222         self.sock, addrs = connect(url, self.sock_opt, proxy_info(**options),
--> 223                                    options.pop('socket', None))
    224 
    225         try:

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/websocket/_http.py in connect(url, options, proxy, socket)
    111 
    112     addrinfo_list, need_tunnel, auth = _get_addrinfo_list(
--> 113         hostname, port, is_secure, proxy)
    114     if not addrinfo_list:
    115         raise WebSocketException(

/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/websocket/_http.py in _get_addrinfo_list(hostname, port, is_secure, proxy)
    152             return addrinfo_list, True, pauth
    153     except socket.gaierror as e:
--> 154         raise WebSocketAddressException(e)
    155 
    156 

WebSocketAddressException: [Errno 8] nodename nor servname provided, or not known

Do you mind to help me out?

gmuraru commented 5 years ago

I think you should start the websocker_server with the id alice. alice = WebsocketClientWorker(id="alice", port=8777, **kwargs_websocket_alice) - here you are trying to connect to alice, but from what you say you created the server with the id bob: python3 run_websocket_server.py --port 8778 --id bob

Could you try with bob?

ZhechunZhou commented 5 years ago

I don't think that is the reason. I tired to connect the both servers. Even after I use only one raspberry pi with bob, the problem remains.

gmuraru commented 5 years ago

Sorry for the late response. Could you write what command you use to run the server on the raspberry PI? Did you try with the following? python run_websocket_server.py --port <port> --id <id>

github-actions[bot] commented 4 years ago

This issue has been marked stale because it has been open 30 days with no activity. Leave a comment or remove the stale label to unmark it. Otherwise, this will be closed in 7 days.