python - 使用嗅探与 python elasticsearch 客户端解决死 TCP 连接问题

标签 python elasticsearch django-haystack

我的应用程序中的 Python elasticsearch 客户端存在连接问题(拒绝连接),因为空闲 TCP 连接因防火墙而超时(我无法阻止这种情况)。

解决这个问题的最简单方法是,如果我可以通过定期发送一些数据来防止连接空闲,elasticsearch 客户端中的嗅探选项似乎很适合这个,但它们是 not very well documented :

sniff_on_start – flag indicating whether to obtain a list of nodes from the cluser at startup time

sniffer_timeout – number of seconds between automatic sniffs

sniff_on_connection_fail – flag controlling if connection failure triggers a sniff

sniff_timeout – timeout used for the sniff request - it should be a fast api call and we are talking potentially to more nodes so we want to fail quickly. Not used during initial sniffing (if sniff_on_start is on) when the connection still isn’t initialized.

我希望客户端每(比如说)5 分钟嗅探一次,我应该使用 sniff_timeout 还是 sniffer_timeout 选项?另外,是否应该将 sniff_on_start 参数设置为 True

最佳答案

我使用了 @val 中的建议并发现这些设置解决了我的问题:

sniff_on_start=True
sniffer_timeout=60
sniff_on_connection_fail=True

嗅探在 TCP 连接上放置了足够的流量,因此它们永远不会闲置足够长的时间,以至于我们的防火墙无法终止连接。

关于python - 使用嗅探与 python elasticsearch 客户端解决死 TCP 连接问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40865611/

相关文章:

linux - 脚本填充值警报

python - 尝试安装 django-haystack

python - 如果 numpy 已经链接到 BLAS(例如 MKL),那么值得使用 cython

python - 从服务器端模型生成无状态客户端表单?

elasticsearch - 创建具有30-40或更多列的索引时,我应该了解/关注什么?

python - 导入错误 : cannot import name generic

django - Django 的 Haystack 是什么?

python - 将连字符与换行符相结合

python - Tkinter 无法连接到显示器 ":0"

spring - JHipster-使用来自Elasticsearch的API调用对实体进行动态过滤-如何以适当的方式使用angular5实现它?