简体   繁体   English

Elasticsearch Python 对远程主机的索引操作不起作用(连接被拒绝)但 cURL 工作正常

[英]Elasticsearch Python indexing operation to remote host doesn't work (connection refused) but cURL works fine

I have a remote host that I'd like to write to with elasticsearch's python client.我有一个远程主机,我想用 elasticsearch 的 python 客户端写入。 I have the elasticsearch service up and running on my remote host, and I have a connection/client set up:我在远程主机上启动并运行了 elasticsearch 服务,并且设置了连接/客户端:

conn = elasticsearch.Urllib3HttpConnection(host='https://my_host.net', port=9200, ssl_version='SSLv2')
es = Elasticsearch(connection=conn)

also, curl my_host.net:9200 works just fine.此外, curl my_host.net:9200工作得很好。 But running es.index(whatever) doesn't work.但是运行es.index(whatever)不起作用。 Any ideas why?任何想法为什么?

Set the Elasticsearch host and port:设置 Elasticsearch 主机和端口:

es_host = 'https://my_host.net:9200'

Connect to the Elasticsearch host:连接到 Elasticsearch 主机:

es = Elasticsearch(hosts=[es_host])

Hope this works in your case.希望这适用于您的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 glibc rand()不适用于python,但在在线编译器中可以正常工作 - glibc rand() doesn't work with python but works fine in online compiler 使用 cURL 的 HTTP 请求有效,但在 Python 请求中无效 - HTTP request using cURL works but doesn't work in Python requests 消息后,套接字断开连接(远程主机拒绝连接),使用python - Socket disconnected after a message, (Connection refused by remote host), using python curl可在localhost上运行,但不能远程运行 - curl works on localhost but it doesn't work remotely 套接字连接被拒绝:telnet:无法连接到远程主机:连接被拒绝 - socket connection refused: telnet: Unable to connect to remote host: Connection refused Curl有效,但Python请求无效 - Curl Works, but Python Requests Doesn't Python — Curl有效,请求lib不起作用 - Python — Curl works, requests lib doesn't 卷毛有效,但python请求不起作用 - Curl works but python requests doesn't 在我的PC上正常工作的Python代码在我的Raspberry Pi上不起作用 - Python code that works fine on my PC doesn't work on my Raspberry Pi 通过终端运行时,Python脚本无法正常运行,但在Jupyter和Visual Studio中可以正常运行 - Python script doesn't work properly when ran through terminal, but works fine in Jupyter and Visual Studio
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM