Thanks for your answer, Baptiste. But I don't get your point. I can't see any discrepancies. Could you give me a hint what are you talking about?
>> => bind's port is being used for health checks => If multiple bind are >> present, the first one is used. ------------------------------ listen another_example bind :1999 option httpchk HEAD / server zd-activemq-s21 10.50.241.93:2000 check ------------------------------ Do you really mean that in the example above haproxy should use port 1999 for the health check? IMHO port 2000 should be used. I copied from the documentation rom haproxy 1.6.3 for option "check" in statement "server". -------------------------- check This option enables health checks on the server. By default, a server is always considered available. If "check" is set, the server is available when accepting periodic TCP connections, to ensure that it is really able to serve requests. The default address and port to send the tests to are those of the server, and the default source is the same as the one defined in the backend.... --------------------------- My example configuration contains 2 listeners, no frontend/backends. I do exactly what is described in the documentation. I don't define explicitly ports for the health check. And I sent already the pointer to the source code where the errors occur. The 2 listeners used should demonstrate the failure. They are not used in reality. Backends: 10.50.241.94: both instances down 10.50.241.93: 2 instances up on ports 8162, 8163 First listener: listen activemq-works bind :8162 option httpchk HEAD / server zd-activemq-s21 10.50.241.93:+1 check server zd-activemq-s22 10.50.241.94:+1 check The listener in haproxy should bind to 8162. The bind to the backend server should be to 8162 + offset (+1) = 8163. The health check should be done with 8163. But the health check IS done with 8162 not 8163. This works because there are 2 running instances of activemq with ports 8162 and 8163. But the wrong instance is used for the health check. The failure is demonstrated in listener 2. listen activemq-doesnotwork bind :18161 option httpchk HEAD / server zd-activemq-s21 10.50.241.93:+1 check server zd-activemq-s22 10.50.241.94:+1 check The listener in haproxy should bind to 8161. The bind to the backend server should be to 8161 + offset (+1) = 8162. The health check should be done with 8162. With listener activemq-doesnotwork no servers are found because port 8161 for the health check is used. See the output of haproxy in my first post. And that is wrong. Following the documentation the port for the health check should be the port for the backend service if not defined explicitly. Andreas -----Ursprüngliche Nachricht----- Von: Baptiste [mailto:[email protected]] Gesendet: Montag, 8. Februar 2016 08:41 An: Grüninger, Andreas (LGL Extern) Cc: [email protected] Betreff: Re: Offset in server definition not usable in 1.6.3 On Sun, Feb 7, 2016 at 9:43 AM, Grüninger, Andreas (LGL Extern) <[email protected]> wrote: > Hello folks > > > > Haproxy 1.6.3. > > Compiled in OpenIndiana with kernel from December 2015 (illumos-cbff3ab). > > > > I would like to use an offset for the ports in the server definition. > > > > We have several pairs of message brokers in a master/slave scenario > with up to three instances of the admin console listening on the ports > 8161, 8162, > 8163 (prod, test, dev). > > > > What I would like to use is e.g. > > ... > > bind :28161,:28162,:28163 > > ... > > server .... <IPADDRESS OF TARGET>:-20000 > > ... > > > > This does not work because the health checks don't respect the server > flag SRV_F_MAPPORTS. > > This flag is set when during parsing the offset is recognized and used > in backend.c (line 787). > > It should be used in checks.c in connect_conn_chk (line 1421). > > Line numbers are from version 1.6 from the sources found in github. > > > > In the following I use the scenario with 2 instances 8162 and 8163. > > Both instances are running on zd-activemq-s22 and are down on > zd-activemq-s21. > > The first proxy works but the health check uses the wrong instance. > > The health check uses port 8162 and the connection will be made with > port 8163. > > The second proxy does not work at all. > > The health check uses 8161 where no instance is listening. > > No target servers are found and the proxy is not usable. > > > > # cat /opt/etc/haproxy-test.cfg > > global > > maxconn 4096 > > > > defaults > > log global > > mode http > > option dontlog-normal > > retries 3 > > maxconn 2000 > > timeout connect 5000 > > timeout client 50000 > > timeout server 50000 > > > > listen statistics > > bind :1935 > > stats enable > > stats uri /haproxy?stats > > stats auth admin:admin > > > > listen activmq-works > > bind :8162 > > option httpchk HEAD / > > server zd-activemq-s21 10.50.241.93:+1 check > > server zd-activemq-s22 10.50.241.94:+1 check > > > > listen activmq-doesnotwork > > bind :18161 > > option httpchk HEAD / > > server zd-activemq-s21 10.50.241.93:+1 check > > server zd-activemq-s22 10.50.241.94:+1 check > > > > > > # haproxy -f /opt/etc/haproxy-test.cfg > > [WARNING] 037/091117 (29237) : Server activmq-works/zd-activemq-s21 is > DOWN, > reason: Layer4 connection problem, info: "Connection refused", check > duration: 0ms. 1 active and 0 backup servers left. 0 sessions active, > 0 requeued, 0 remaining in queue. > > [WARNING] 037/091118 (29237) : Server > activmq-doesnotwork/zd-activemq-s21 is DOWN, reason: Layer4 connection > problem, info: "Connection refused", check > duration: 0ms. 1 active and 0 backup servers left. 0 sessions active, > 0 requeued, 0 remaining in queue. > > [WARNING] 037/091118 (29237) : Server > activmq-doesnotwork/zd-activemq-s22 is DOWN, reason: Layer4 connection > problem, info: "Connection refused", check > duration: 0ms. 0 active and 0 backup servers left. 0 sessions active, > 0 requeued, 0 remaining in queue. > > [ALERT] 037/091118 (29237) : proxy 'activmq-doesnotwork' has no server > available! > > > > > > > > Regards > > > > Andreas Hi Andreas, First, there are some inconsistencies between your description and your configuration example. Could you please check and resend your example in case I misunderstood where your problem is? That said, you may want to precise the port you want to check: listen activmq-fix bind :18161 option httpchk HEAD / server zd-activemq-s21 10.50.241.93:+1 check port 8161 server zd-activemq-s22 10.50.241.94:+1 check port 8161 Something important to note, is that HAProxy's behavior is not the same with those 2 configurations: 1: listen example1 bind :18161 option httpchk HEAD / server zd-activemq-s21 10.50.241.93:+1 check server zd-activemq-s22 10.50.241.94:+1 check => bind's port is being used for health checks => If multiple bind are present, the first one is used. 2: frontend f_example2 bind :18161 default_backend b_example2 backend b_example2 option httpchk HEAD / server zd-activemq-s21 10.50.241.93:+1 check server zd-activemq-s22 10.50.241.94:+1 check => this configuration is invalid and an ALERT is returned because backend b_example doesn't know to which TCP port it is supposed to get connected to send the health check. Baptiste

