WS communication failure using forwardfor option in haproxy

I have the following scenario. I have a biometric device that is connecting to my application using websocket. I need the remote IP of the connection to be returned in the log, but it was returning the host’s IP.

I found in the documentation a suggestion to use the “option forwardfor” which solved the IP problem and started showing me the remote IP. But unfortunately, this stopped the communication and I started receiving the error “Oct 7 11:08:35 ip-172-31-27-83 bash[567]: java.io.IOException: Connection closed by the other end”.

I’m using Haproxy version 2.4.22-0ubuntu0.22.04.3 and it’s configured like this

frontend http-in
bind :::80 v4v6
bind :::443 v4v6 ssl crt /home/tomcat/Certificado/exemplo.pem alpn h2,http/1.1
redirect scheme https code 301 if !{ ssl_fc }
#option forwardfor

acl acl_test hdr(host) -i teste.exemplo.app

backend backend_test
server server_test server ip:port maxconn 100000

Note: without the forwardfor option the communication works, but the IPhost appears and with the forwardfor option active, the communication doesn’t work, but it shows the ipremoto.

Where am I going wrong?