HAProxy community

Error when working with grpc


Hello, we have problems with haproxy 1.9.4 when working with grpc.

We use bidirectional streaming of data and receive this error every 30 seconds (it’s timeout server in our configuration).

io.grpc.StatusRuntimeException: UNAVAILABLE: HTTP status code 504
invalid content-type: text/html
headers: Metadata(:status=504,cache-control=no-cache,content-type=text/html)
<html><body><h1>504 Gateway Time-out</h1>
The server didn't respond in time.

Our configuration:

	log	global
	mode	http
	option	httplog
	option  socket-stats
	option  logasap 
	option  http-use-htx
    option  forwardfor
	timeout connect 30000
    timeout client  30s
    timeout server  30s
    errorfile 400 /etc/haproxy/errors/400.http
    errorfile 403 /etc/haproxy/errors/403.http
    errorfile 408 /etc/haproxy/errors/408.http
    errorfile 500 /etc/haproxy/errors/500.http
    errorfile 502 /etc/haproxy/errors/502.http
    errorfile 503 /etc/haproxy/errors/503.http
    errorfile 504 /etc/haproxy/errors/504.http

frontend main-http-grpc
    description  http:8080,grpc:9090 
	option  http-use-htx
    option forwardfor
	bind *:8080 name main-http 
	bind *:9090 name main-grpc proto h2
	acl http dst_port eq 8080
	acl grpc dst_port eq 9090

	use_backend  testhost if http { hdr_beg(host) -i testhost.local }
	use_backend  testhost-grpc if grpc { hdr_beg(host) -i testhost.local }

backend testhost
        description  http
        option forwardfor
        option httpchk OPTIONS /status
        server testhost1 check
        server testhost2 check backup disabled

backend testhost-grpc
	option http-use-htx
    description grpc
    server testhost1 proto h2 track testhost/testhost1
    server testhost2 proto h2 track testhost/testhost2 backup disabled

What could be the problem?
Thanks in advance.