user2914191
user2914191

Reputation: 897

haproxy + spring boot writeAddress(..) failed: Connection reset by peer

I'm running HAproxy with backend Spring Boot Rest controllers. My spring log shows constant errors that look like the following:

[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 performs an HTTP check on the url /api/v1/status. What would be the reason that I'm getting these errors?

HAProxy Config

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

Upvotes: 0

Views: 1244

Answers (1)

bidisha mukherjee
bidisha mukherjee

Reputation: 745

HAproxy is doing GET request, reads http response code and closing connection. Boot is trying to send remaining parts (http headers and some json payload) but connection is already closed.

Just replace GET with OPTIONS in the line:

option httpchk GET /api/v1/status HTTP/1.0

Upvotes: 2

Related Questions