【问题标题】:RPyC SSH connectionRPyC SSH 连接
【发布时间】:2017-12-18 22:37:06
【问题描述】:

我正在尝试使用 RPyC 在谷歌云上的 2 个 VM 实例之间建立客户端-服务器连接。我有以下代码:

服务器端:

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] 名称解析暂时失败

我认为这与密钥文件和证书文件有关,但我不确定如何设置它们。有任何想法吗? 谢谢!

【问题讨论】:

    标签: ssh server client cloud rpyc


    【解决方案1】:

    GAIERROR : Get A地址nfo E错误 p>

    名称解析失败时会出现此错误。

    如果两台机器都是 Linux,则在 /etc/hosts 文件中添加条目 或将“myserver”替换为 IP 地址。

    【讨论】:

      【解决方案2】:

      检查名称“myserver”是否可达,否则替换为 IP 地址。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-06-04
        相关资源
        最近更新 更多