Kowshik
Kowshik

Reputation: 1641

Thin server not timing out

The code/documentation for Thin suggests that the default connection timeout is 30s. However, when I try to test this, it doesn't seem to work. What am I missing?

I'm using thin v1.5.0 (the latest).

# Test this using: curl -X GET http://localhost:3000/test. You will find that the request does not
# timeout after 30s.

require 'thin'

class SimpleAdapter
  def call(env)
    sleep 100
    body = ["hello!"]
    [
      200,
     { 'Content-Type' => 'text/plain' },
      body
    ]
  end
end

server = Thin::Server.new('127.0.0.1', 3000) do
  map '/test' do
    run SimpleAdapter.new
  end
end

server.start!

Upvotes: 2

Views: 428

Answers (1)

fresskoma
fresskoma

Reputation: 25781

The inline documentation states the following:

Maximum number of seconds for incoming data to arrive before the connection is dropped.

And Thin correctly displays that behavior, that is, if you telnet into the server:

telnet localhost 3000

and wait for 30 seconds, it drops the connection. However, the cURL command already sends a complete HTTP request to the Thin server, which is why the timeout waiting for incoming data is never reached.

Upvotes: 5

Related Questions