HAProxy community

Monitoring websockets with haproxy 2.2

Greetings - I’m working on upgrading haproxy from 1.8 to 2.2. I went through and corrected all of the warnings but I hit a snag with how we monitor websocket backends. Right now, we do this in the websocket specific backend:

option httpchk GET /ws?healthcheck=true HTTP/1.1\r\nHost:\ foobar.net\r\nConnection:\ Upgrade\r\nUpgrade:\ websocket\r\nSec-WebSocket-Key:\ x3JJHMbDL1EzLkh9GBhXDw==\r\nSec-WebSocket-Version:\ 13
http-check expect status 101

When I change it to the new way:

option httpchk GET /ws?healthcheck=true HTTP/1.1
http-check send hdr Host foobar.net hdr Connection Upgrade hdr Upgrade websocket hdr Sec-WebSocket-Key x3JJHMbDL1EzLkh9GBhXDw== hdr Sec-WebSocket-Version 13
http-check expect status 101

http-check send overwrites the Connection header and sets it to close (per the docs). Here are the headers my app receives when I use http-check send:

  host: 'foobar.net',
  upgrade: 'websocket',
  'sec-websocket-key': 'x3JJHMbDL1EzLkh9GBhXDw==',
  'sec-websocket-version': '13',
  'content-length': '0',
  connection: 'close'

This doesn’t work so I’ve had to revert back to the old deprecated way of doing this.

Is there any way to monitor websockets like we were doing with option httpchk? I’ve been reading through the docs, searching here and elsewhere, and I haven’t found anything. It doesn’t look like this is possible with 2.2 yet.