Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    HAProxy json-rpc healthcheck - need help with my example

    Scheduled Pinned Locked Moved Cache/Proxy
    5 Posts 1 Posters 1.7k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      andyc23
      last edited by andyc23

      Hi:
      I'm using a Netgate 6100

      I'm trying to get a health check to work on haproxy for my backend - it's accepted as valid but not getting the expected result back.

      my backends run on port 8545 (this is what i'm forwarding to)
      the same port has an rpc interface of which i can do the health check.

      locally on the server i can run this (and externally):

      curl -X POST --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' http://localhost:8545/ -H "Content-Type: application/json"
      

      and it responds with

      {"jsonrpc":"2.0","id":1,"result":false}
      

      if the result is "false" it means it's "up" and ready to serve.

      In my backend advanced passthru for the backed I have tried this, which is "accepted" as correct format however it shows my server is down (expected response back isn't correct).

      option httpchk POST / HTTP/1.1
      http-check send hdr Content-Type application/json  body {"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}
      http-check expect string false
      

      How can I debug this or can anyone help ?

      Thanks in advance

      note: a normal basic health check works, however this only shows the service is running, not that it is in a "ready state".

      A 1 Reply Last reply Reply Quote 0
      • A
        andyc23 @andyc23
        last edited by

        Happy to pay the going rate for support for this.

        A 1 Reply Last reply Reply Quote 0
        • A
          andyc23 @andyc23
          last edited by andyc23

          @andyc23
          I solved this by having this in the advanced pass through.
          Hope it helps someone else:

          option httpchk POST / HTTP/1.1\r\nHost:\ haproxyservices\r\nContent-Type:\ application/json\r\nContent-Length:\ 76\r\n\r\n"{\"jsonrpc\":\"2.0\",\"method\":\"eth_syncing\",\"params\":[],\"id\":1}"
          http-check expect string false
          

          I do get a warning though >

          [WARNING] 185/013305 (92736) : parsing [/var/etc/haproxy/haproxy.cfg:132]: 'option httpchk' : hiding headers or body at the end of the version string is deprecated. Please, consider to use 'http-check send' directive instead.
          

          not sure if important.

          A 1 Reply Last reply Reply Quote 0
          • A
            andyc23
            last edited by

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • A
              andyc23 @andyc23
              last edited by

              @andyc23 said in HAProxy json-rpc healthcheck - need help with my example:

              @andyc23
              I solved this by having this in the advanced pass through.
              Hope it helps someone else:

              option httpchk POST / HTTP/1.1\r\nHost:\ haproxyservices\r\nContent-Type:\ application/json\r\nContent-Length:\ 76\r\n\r\n"{\"jsonrpc\":\"2.0\",\"method\":\"eth_syncing\",\"params\":[],\"id\":1}"
              http-check expect string false
              

              I do get a warning though >

              [WARNING] 185/013305 (92736) : parsing [/var/etc/haproxy/haproxy.cfg:132]: 'option httpchk' : hiding headers or body at the end of the version string is deprecated. Please, consider to use 'http-check send' directive instead.
              

              not sure if important.

              Sorry for bumping this old thread.

              I had everything working as above, but now, since i've updated haproxy -

              i now get this issue:

              [ALERT] (50668) : config : parsing [/var/etc/haproxy_test/haproxy.cfg:181] : 'option httpchk' : hiding headers or body at the end of the version string is unsupported.Use 'http-check send' directive instead..

              i've tried:

              http-check send meth POST uri / ver HTTP/1.1 hdr Host haproxyservices hdr Content-Type application/json hdr Content-Length 60 body "{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}"
              http-check expect string false

              anyone able to help me set the correct backend passthru?

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.