Python 无法通过ssh使用Elasticsearch类和远程服务器建立连接

elasticsearch.exceptions.ConnectionError: ConnectionError(<urllib3.connection.HTTPConnection object at 0x000001B539AC6C10>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。) caused by: NewConnectionError(<urllib3.connection.HTTPConnection object at 0x000001B539AC6C10>: Failed to establish a new connection: [WinError 10061] 由于目标计算机积极拒绝,无法连接。)

python
server = SSHTunnelForwarder(
            ssh_address_or_host=(ssh_ip, ssh_port),  # 指定ssh登录的跳转机的address
            ssh_username='root',  # 跳转机的用户
            ssh_pkey="D:/share/id_rsa",
            # 单 -远程服务器地址+端口
            # remote_bind_address=(host, 3306),
            # 多 -远程服务器地址+端口
            remote_bind_addresses=[
                (host, port),  # sql
                (es_host, es_port)   # es

            ]
        )

es = Elasticsearch(
            ['127.0.0.1:9200'],  # 连接集群,以列表的形式存放各节点的IP地址
            # sniff_on_start=True,    # 连接前测试
            sniff_on_connection_fail=True,  # 节点无响应时刷新节点
            sniff_timeout=100,  # 设置超时时间
            # http_auth=('es', 'password'),  # ES用户名密码
            port=server.local_bind_ports[1]  # 端口号
        )

        print(es)
        data = es.search(index='person_file', doc_type='doc', body={"query": {"match_all": {}}})
        print(data)

以上是我的代码 ,sql连接是没问题的证明那个,ssh是没问题的 但是es出现了上述的错误

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.