unknown transfer encoding HTTP error

Issue #831 resolved
Maksym Tiurin created an issue

In the last monit version 5.25.3 http headers check was added. Unfortunately, it’s broke services check using HTTP protocol.

Application to monitor - EJBCA. Config file is:

check process ejbca with matching "java .*jboss-modules.jar.*standalone.xml"
      group ejbca
      start program = "/etc/ejbca/run_ejbca start"
      stop program  = " /etc/ejbca/run_ejbca stop"
      restart program = "/etc/ejbca/run_ejbca restart"
      # JBoss management port
      if failed host 127.0.0.1 port 9990 type TCP
         TIMEOUT 60 SECONDS
         within 3 cycles then restart
      # EJBCA
      if failed URL http://127.0.0.1:8080/ejbca
         TIMEOUT 60 SECONDS
         within 3 cycles then restart
      # EJBCA SSL
      if failed host 127.0.0.1 port 8443 type TCPSSL
        TIMEOUT 60 SECONDS
        within 3 cycles then restart
      # EJBCA health check
      if failed URL http://127.0.0.1:8080/ejbca/publicweb/healthcheck/ejbcahealth
        content = "ALLOK"
        timeout 60 seconds
        within 5 cycles then alert
      if 5 restarts within 5 cycles then timeout
      mode manual

EJBCA health check doesn’t work in new release. Monit logs following error:

'ejbca' failed protocol test [HTTP] at [127.0.0.1]:8080/ejbca/publicweb/healthcheck/ejbcahealth [TCP/IP] -- HTTP error: uknown transfer encoding

EJBCA uses ‘chunked’ transfer encoding.

curl -v http://127.0.0.1:8080/ejbca/publicweb/healthcheck/ejbcahealth
* About to connect() to 127.0.0.1 port 8080 (#0)
*   Trying 127.0.0.1...
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET /ejbca/publicweb/healthcheck/ejbcahealth HTTP/1.1
> User-Agent: curl/7.29.0
> Host: 127.0.0.1:8080
> Accept: */*
> 
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Content-Type: text/plain;charset=ISO-8859-1
< Transfer-Encoding: chunked
< Date: Fri, 21 Jun 2019 01:21:56 GMT
< 
* Connection #0 to host 127.0.0.1 left intact
ALLOK

Please do transfer encoding check optional or add configuration parameter to extend allowed transfer encodings.

Comments (7)

  1. Tildeslash repo owner

    The Monit 5.25.3 has support for chunked encoding (no configuration is necessary) … please is it possible to test your http server remotely so we can try to reproduce?

    If remote access is not possible, please can you start monit in verbose mode (using -v option) and send us the log + collect a network trace (using for example wireshark)?

  2. Mario Aeby

    I just upgraded from 5.20 to

    ii  monit                                1:5.26.0-4                        amd64        utility for monitoring and managing daemons or similar programs
    

    and immediately started to receive the same alert:

    failed protocol test [HTTP] at [10.1.2.3]:4022/status/ [TCP/IP] -- HTTP error: unknown transfer encoding
    

    The monit check queries the mini webserver of udpxy:

    check host iptv-local.domain.local with address 10.1.2.3
        start program = "..."
        stop program = "..."
        if failed
            port 4022
            protocol http
            request "/status/"
            with content = "Cherenkov"
            for 5 cycles
        then restart
    

    Debugging the server response with cURL yields:

    $ curl -v 10.1.2.3:4022/status/
    *   Trying 10.1.2.3...
    * TCP_NODELAY set
    * Connected to 10.1.2.3 (10.1.2.3) port 4022 (#0)
    > GET /status/ HTTP/1.1
    > Host: 10.1.2.3:4022
    > User-Agent: curl/7.52.1
    > Accept: */*
    > 
    * HTTP 1.0, assume close after body
    < HTTP/1.0 200 OK
    < Content-type: text/html
    < 
    <html>
    <head>
    <style type="text/css">
    ...
    <div id="footer">udpxy v. 1.0 (Build 23) lean - [Sun Feb 23 10:46:18 2020]<br>udpxy and udpxrec are Copyright (C) 2008-2018 Pavel V. Cherenkov and licensed under GNU GPLv3</div>
    ...
    </body>
    </html>
    * Curl_http_done: called premature == 0
    * Closing connection 0
    

    Observations:

    • HTTP 1.0
    • No Content-Length: header

  3. Tildeslash repo owner

    Fixed: Issue #831: The HTTP protocol test returned "unknown transfer encoding HTTP error" in the case that the HTTP server didn't set the Content-Length nor used a chunked encoding for response.

    → <<cset 7e09bfbccb75>>

  4. Log in to comment