HAProxy community

Setting up reverse proxy to container in swarm

Hi I am trying to proxy two mqtt broker on same docker swarm through through single port by using SNI. My HAProxy config is

resolvers docker
  nameserver dns "127.0.0.11:53"
defaults
  timeout client 30s
  timeout server 30s
  timeout connect 5s
listen mqtt
  bind *:1883
  use-server mqtt_app_1 if { req_ssl_sni -i mqtt1.ns1.logicbee.dev }
  server     mqtt_app_1 mqtt_1:1883 check resolvers docker resolve-prefer ipv4
  use-server mqtt_app_2 if { req_ssl_sni -i mqtt2.ns1.logicbee.dev }
  server     mqtt_app_2 mqtt_2:1883 check resolvers docker resolve-prefer ipv4

i got the below error

mult_serv_proxy2.1.sm4o91a6ocw7@node0    | [NOTICE] 195/185652 (1) : haproxy version is 2.2.0
mult_serv_proxy2.1.sm4o91a6ocw7@node0    | [NOTICE] 195/185652 (1) : path to executable is /usr/local/sbin/haproxy
mult_serv_proxy2.1.sm4o91a6ocw7@node0    | [ALERT] 195/185652 (1) : parsing [/usr/local/etc/haproxy/haproxy.cfg:12] : 'server mqtt_app_1' : could not resolve address 'mqtt_1'.
mult_serv_proxy2.1.sm4o91a6ocw7@node0    | [ALERT] 195/185652 (1) : parsing [/usr/local/etc/haproxy/haproxy.cfg:14] : 'server mqtt_app_2' : could not resolve address 'mqtt_2'.
mult_serv_proxy2.1.sm4o91a6ocw7@node0    | [ALERT] 195/185652 (1) : Failed to initialize server(s) addr.
mult_serv_proxy2.1.42p4r0h5exw6@node0    | [NOTICE] 195/185659 (1) : New worker #1 (7) forked

my swarm setup works well for httpd proxied by nginx.
When I ping from inside the haproxy container I got the following

How to solve this?