2

I have a Go server that reverse proxies requests to an Apache/PHP server. I have been able to rarely observe that on occasion, the Apache/PHP server will cause Go to produce the following error message: malformed HTTP response "false". The requests are identical, and I can sit and refresh a page in a browser which follows that request path, and have the error happen maybe one in a hundred times. I haven't been able to observe any pattern as to when it will happen or not. There is nothing in any access log, error log, or system log that seems relevant.

I have been able to make Go produce that error message with the below code, so it looks like Apache must be sending invalid responses, writing the string "false" directly to a TCP connection.

Any clues to this would be greatly appreciated.

Request:

package main

import (
    "fmt"
    "net/http"
    "net/http/httputil"
)

func main() {
    req, _ := http.NewRequest("GET", "http://127.0.0.1:36302", nil)
    resp, err := http.DefaultClient.Do(req)
    if err != nil {
        panic(err)
    }
    respDump, _ := httputil.DumpResponse(resp, true)
    fmt.Println(string(respDump))
}

Server:

package main

import (
    "fmt"
    "io"
    "net"
    "time"
)

func main() {
    l, _ := net.ListenTCP("tcp4", &net.TCPAddr{net.ParseIP("127.0.0.1"), 36302, ""})
    for {
        fmt.Println("Accepting connections")
        c, err := l.AcceptTCP()
        if err != nil {
            fmt.Println(err)
        }
        time.Sleep(1 * time.Second)
        io.WriteString(c, "false")
        time.Sleep(1 * time.Second)
        c.Close()
    }
}
4
  • I'm confused - if Apache with PHP is the server, what's the code you've labeled as "Server"? Aug 11, 2014 at 17:45
  • 1
    I was just trying to confirm the behavior that would lead Go to produce this particular error message. That sample server makes the error happen on every request by just writing the raw string "false" to a received TCP connection. It heavily suggests to me that Apache or PHP must be doing the same thing, but I can't see why or how. Aug 11, 2014 at 18:01
  • Ahh, got it. How frequently is it happening - I wonder if you can snag an occurrence of the problem with tcpdump? Aug 11, 2014 at 20:57
  • When requesting manually, it seems like it happens once or twice ... sometimes, and then doesn't happen again for a long time. This is on the order of several dozen manual requests each time. I'm working on getting some better metrics off of the servers. Aug 11, 2014 at 21:09

0

You must log in to answer this question.

Browse other questions tagged .