Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

通过网关访问集群,当请求返回结果为空时,网关会认为节点不可用 #66

Open
liukuijun666 opened this issue Jan 16, 2025 · 0 comments

Comments

@liukuijun666
Copy link
Contributor

liukuijun666 commented Jan 16, 2025

Problem description

通过网关访问集群,当请求返回结果为空时,网关会认为节点不可用

场景

集群配置跨域

http.cors.enabled: true
http.cors.allow-origin: "*"

默认允许的 Method 有:OPTIONS,HEAD,GET,POST,PUT,DELETE。

使用异常 Method 直接请求集群

# curl -ku'admin:xxx' -H'Content-Type: application/json' -X PRI https://10.0.0.1:9205/_cat/indices
curl: (52) Empty reply from server

使用异常 Method 通过网关请求集群

# curl -ku'admin:xxx' -H'Content-Type: application/json' -X PRI http://10.0.0.1:8002/_cat/indices
{"error":true,"message":"the server closed connection before returning the first response byte. Make sure the server returns 'Connection: close' response header before closing the connection"}

同时网关会输出节点不可用的日志

[01-16 13:39:15] [INF] [actions.go:46] node [10.0.0.1:9206] is not available

当异常的请求足够多,所有的节点都被认为不可用时,网关会输出集群不可用的日志

[01-16 13:39:15] [INF] [actions.go:345] es_cluster_test has active hosts: 0
[01-16 13:39:15] [INF] [actions.go:354] elasticsearch [es_cluster_test] is not available

在网关输出集群不可用日志后,正常的请求也会失败。

# curl -u'admin:xxx' -H'Content-Type: application/json' -X GET http://localhost:8002/_cat/indices
{"error":true,"message":"Elasticsearch [es_cluster_test] Service Unavailable"}

当网关输出集群可用的日志后,正常的请求才会成功。

[01-16 13:58:34] [INF] [actions.go:377] elasticsearch [es_cluster_test] is available
# curl -u'admin:xxx' -H'Content-Type: application/json' -X GET http://localhost:8002/_cat/indices
green open .security CyFkDI31Rj-Q5ybreWit3Q 1 2 8 0 114.8kb 38.2kb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant