【问题标题】:Thin server not timing out瘦服务器未超时
【发布时间】:2012-11-25 02:14:30
【问题描述】:

Thin 的代码/文档建议默认连接超时为 30 秒。但是,当我尝试对此进行测试时,它似乎不起作用。我错过了什么?

我使用的是thin v1.5.0(最新)。

# 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!

【问题讨论】:

  • 您能否参考建议 30 秒超时的文档?
  • 如果你看代码,DEFAULT_TIMEOUT 设置为 30s。此外,如果您使用命令行运行器并执行“thin -h”,则帮助建议如下:“-t, --timeout SEC 请求或命令超时秒(默认值:30)”。

标签: ruby http timeout webserver thin


【解决方案1】:

内联文档声明如下:

连接断开前传入数据到达的最大秒数。

并且 Thin 正确显示了该行为,也就是说,如果您 telnet 进入服务器:

telnet localhost 3000

并等待 30 秒,它会断开连接。 但是,cURL 命令已经向瘦服务器发送了一个完整的 HTTP 请求,这就是为什么永远不会达到等待传入数据的超时时间。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-08-26
    • 1970-01-01
    • 1970-01-01
    • 2012-11-02
    • 2016-03-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多