2017-12-18 24 views
0

RPyCを使用してクライアントとサーバー間の接続を確立しようとしていますが、Googleのクラウド上に2つのVMインスタンスがあります。RPyC SSH接続

サーバ側:私は、次のコードを持っている

import rpyc 

class MyService(rpyc.Service): 
    def on_connect(self): 
     # code that runs when a connection is created 
     # (to init the serivce, if needed) 
     pass 

    def on_disconnect(self): 
     # code that runs when the connection has already closed 
     # (to finalize the service, if needed) 
     pass 

    def exposed_get_answer(self): # this is an exposed method 
     return 42 

    def get_question(self): # while this method is not exposed 
     return "what is the airspeed velocity of an unladen swallow?" 

if __name__ == "__main__": 
     from rpyc.utils.server import ThreadedServer 
     from rpyc.utils.authenticators import SSLAuthenticator 
     authenticator = SSLAuthenticator("myserver.key", "myserver.cert") 
     server = ThreadedServer(MyService, port=12345, authenticator=authenticator) 
     server.start() 

クライアント側:

import rpyc 

conn = rpyc.ssl_connect("myserver", port = 12345, keyfile=None, 
         certfile=None) 
conn.execute("print ('world')") 

私はClient.pyを実行すると、私は次のエラーを取得

socket.gaierror: [Errno -3] Temporary failure in name resolution

私はそう思いますkeyfileとcertfileと関係がありますが、設定方法がわかりません。何か案は? ありがとうございました!

答えて

0

名前が「myserver」に到達可能であることを確認し、そうでなければIPアドレスで置き換えます。