1

I'm trying to write a web server in golang to handle geocoding requests. Some of these requests take longer than a minute to process. In this case, the server seems to be returning an empty body to the client, though the handler keeps running. I've tried the code below to no avail. Am I missing something? Is it possible this is a problem with pat?

r := pat.New()

r.Get("/geocode", GeocodeHandler)
r.Get("/status", StatusHandler)
r.Get("/", InvalidHandler)

s := &http.Server{
    Addr: ":"+port,
    Handler: r,
    ReadTimeout: 10 * time.Minute,
    WriteTimeout: 10 * time.Minute,
    MaxHeaderBytes: 0,
}

s.ListenAndServe()

The client is in ruby. I don't believe that's the problem though, since I see similar behavior if I use curl.

uri = URI(URI.escape("http://blah.com/geocode?address=#{address}"))
http = Net::HTTP.new(uri.host, uri.port)
http.read_timeout = 10 * 60
response = http.request(Net::HTTP::Get.new(uri.request_uri))
halfelf
  • 9,737
  • 13
  • 54
  • 63
MattyB
  • 909
  • 2
  • 9
  • 15
  • 1
    Check if your client is timing out. – thwd Jul 17 '13 at 07:45
  • Is the empty body being returned before the request has completed processing? Or does the processing finish and then the empty body is returned? This should hopefully indicate if the timeout is on the server or client side. – Intermernet Jul 17 '13 at 08:50
  • @Tom : I'm having the same issue if I use curl as the client. I've attached the ruby client though for reference. – MattyB Jul 17 '13 at 14:35

1 Answers1

3

Found the issue. I didn't mention that my server was behind an Amazon ELB. Its default timeout is 60 seconds.

MattyB
  • 909
  • 2
  • 9
  • 15