spring - haproxy + spring boot writeAddress(..)失败:对等方重置连接
问题描述
我正在使用后端 Spring Boot Rest 控制器运行 HAproxy。我的 spring 日志显示如下所示的持续错误:
[reactor-http-epoll-26] ERROR o.s.w.s.a.HttpWebHandlerAdapter - [9df8bfcf] Error [io.netty.channel.unix.Errors$NativeIoException: writeAddress(..) failed: Connection reset by peer] for HTTP GET "/api/v1/status", but ServerHttpResponse already committed (200 OK)
HAproxy 对 url 执行 HTTP 检查/api/v1/status
。我收到这些错误的原因是什么?
HAProxy 配置
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
# daemon
# turn on stats unix socket
stats socket /var/lib/haproxy/stats
ssl-default-bind-ciphers EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH+aRSA+RC4:EECDH:EDH+aRSA:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EX$
ssl-default-bind-options no-sslv3 no-tlsv10
tune.ssl.default-dh-param 4096
defaults
mode http
log global
option httplog
option http-server-close
option forwardfor except 127.0.0.0
option redispatch
retries 3
timeout http-request 30s
timeout queue 1m
timeout connect 30s
timeout client 30s
timeout server 30s
frontend https-in
bind *:443 ssl crt /etc/cert.pem
default_backend api
backend api
mode http
option httpchk GET /api/v1/status HTTP/1.0
http-check expect status 200
balance roundrobin
server api1 127.0.0.1:8001 check fall 3 rise 2
server api2 127.0.0.1:8002 check fall 3 rise 2
解决方案
HAproxy 正在执行 GET 请求,读取 http 响应代码并关闭连接。Boot 正在尝试发送剩余部分(http 标头和一些 json 有效负载),但连接已关闭。
只需将 GET 替换为 OPTIONS 即可:
option httpchk GET /api/v1/status HTTP/1.0
推荐阅读
- wordpress - 为什么即使我卸载了 WP-Socializer 插件,我也无法在移动版上删除社交图标?
- php - cURL/GuzzleHTTP 检查直接下载链接的状态码
- python - Python Coverage - 不覆盖函数内容,只是定义
- visual-studio-code - 你如何在 VSCode 中取消拆分终端?
- r - 如何从字符串中删除未知符号?
- python - 如何在 tkinter 中将多个按钮链接到一个文本小部件?
- excel - ActiveWorkbook.Queries.Add 筛选条件
- python - 从我正在使用图像管道的scrapy spider下载/抓取图像时,我遇到了一个值错误
- php - Laravel 队列无法发送邮件
- python - 从文件中读取 16 字节 Fortran 浮点数到 Python