HAProxy community

Trying to use stick-table with tcp content

Hello

i use haproxy (2.07) for balancing incoming tcp connection on port 13 to the same server on port 13,14 & 15
i would like to use the content of the first bytes sent, for the key in the stick table
but the stick table dont add entries and stay empty

here is how i build the cfg :

this is my first working config

frontend port13
bind *:13
default_backend myback

backend myback
mode tcp
balance leastconn
server srv1 <server_ip>:13

the config is working, i added a stick table on ip
backend myback

stick-table type ip size 1m expire 1h
stick on src

this config is working too. i can see entries added with socat
but the IP of my peers change often, so i want to use the peer id which is in the first packet sent.
so i change like that :
stick-table type binary len 25 size 1m expire 1h
stick on req.payload(1,25)

and now, the peers can connect, but no entries are stored in the table. the table remain empty
i ve added in the frontend :
tcp-request inspect-delay 2s
tcp-request content accept if WAIT_END

but it does not change anything
i ve tried to launch in debug mode, but i see nothing of interest

any idea ?

if your peer id is the first thing sent you might want to use req.payload(0,25).
your config works for me if I client sends at least 26 bytes within inspect-delay period.

note that you can write tcp-request content accept if WAIT_END || { req.payload(0,25) -m found } (or req.payload(1,25) if it’s what your need) so you don’t have to wait 2s every time you connect.