2012-03-23 19 views
5

我已經注意到了某些要求,特別是從正常運行時間機器人測試頁面的正常運行時間最近已經開始生成以下機架皮棉錯誤在我的Rails應用程序3.1.X:如何解決Rack Lint錯誤?

21:47:05 web.1  | Started HEAD "/" for 74.86.158.106 at 2012-03-22 21:47:05 -0400 
21:47:05 web.1  | Processing by HomeController#index as */* 
... 
21:47:05 web.1  | /Users/username/.rvm/gems/[email protected]/gems/activesupport-3.1.4/lib/active_support/core_ext/string/output_safety.rb:23: warning: regexp match /.../n against to UTF-8 string 
... 
21:47:05 web.1  | Completed 200 OK in 81ms (Views: 60.3ms | ActiveRecord: 0.0ms) 
21:47:05 web.1  | 74.86.158.106 - - [22/Mar/2012 21:47:05] "GET/HTTP/1.1" 200 31842 0.1993 
21:47:05 web.1  | E, [2012-03-22T21:47:05.546848 #18938] ERROR -- : app error: Content-Length header was 31842, but should be 0 (Rack::Lint::LintError) 
21:47:05 web.1  | E, [2012-03-22T21:47:05.546978 #18938] ERROR -- : /Users/username/.rvm/gems/[email protected]/gems/rack-1.3.6/lib/rack/lint.rb:19:in `assert' 
21:47:05 web.1  | E, [2012-03-22T21:47:05.547079 #18938] ERROR -- : /Users/username/.rvm/gems/[email protected]/gems/rack-1.3.6/lib/rack/lint.rb:501:in `verify_content_length' 
21:47:05 web.1  | E, [2012-03-22T21:47:05.547178 #18938] ERROR -- : /Users/username/.rvm/gems/[email protected]/gems/rack-1.3.6/lib/rack/lint.rb:525:in `each' 
21:47:05 web.1  | E, [2012-03-22T21:47:05.547277 #18938] ERROR -- : /Users/username/.rvm/gems/[email protected]/gems/rack-1.3.6/lib/rack/body_proxy.rb:23:in `method_missing' 
21:47:05 web.1  | E, [2012-03-22T21:47:05.547375 #18938] ERROR -- : /Users/username/.rvm/gems/[email protected]/gems/unicorn-4.2.0/lib/unicorn/http_response.rb:41:in `http_response_write' 
21:47:05 web.1  | E, [2012-03-22T21:47:05.547476 #18938] ERROR -- : /Users/username/.rvm/gems/[email protected]/gems/unicorn-4.2.0/lib/unicorn/http_server.rb:538:in `process_client' 
21:47:05 web.1  | E, [2012-03-22T21:47:05.547574 #18938] ERROR -- : /Users/username/.rvm/gems/[email protected]/gems/unicorn-4.2.0/lib/unicorn/http_server.rb:604:in `worker_loop' 
21:47:05 web.1  | E, [2012-03-22T21:47:05.547672 #18938] ERROR -- : /Users/username/.rvm/gems/[email protected]/gems/unicorn-4.2.0/lib/unicorn/http_server.rb:487:in `spawn_missing_workers' 
21:47:05 web.1  | E, [2012-03-22T21:47:05.547770 #18938] ERROR -- : /Users/username/.rvm/gems/[email protected]/gems/unicorn-4.2.0/lib/unicorn/http_server.rb:137:in `start' 
21:47:05 web.1  | E, [2012-03-22T21:47:05.547867 #18938] ERROR -- : /Users/username/.rvm/gems/[email protected]/gems/unicorn-4.2.0/bin/unicorn:121:in `<top (required)>' 
21:47:05 web.1  | E, [2012-03-22T21:47:05.547966 #18938] ERROR -- : /Users/username/.rvm/gems/[email protected]/bin/unicorn:19:in `load' 
21:47:05 web.1  | E, [2012-03-22T21:47:05.548063 #18938] ERROR -- : /Users/username/.rvm/gems/[email protected]/bin/unicorn:19:in `<main>' 

任何想法,什麼可能是怎麼回事這裏?我現在真的沒有找到解決方案,專門解決在這種情況下要做的事情,只要找到真正可能發生的事情。

回答

1

我知道這是一個老問題,但我有完全相同的問題。來自UptimeRobot和New Relic的請求(僅來自這兩個IP的請求)會提供這些日誌消息。

UptimeRobot和NewRelic都報告'OK'。

看起來不是Rack::Lint抱怨的要求,而是迴應。看看堆棧跟蹤。它來自獨角獸的http_response_write(我也使用獨角獸)。

我會調查更多並在此處添加任何發現。

UPDATE:

我能夠重現該問題與

$ curl https://example.com -X HEAD -i 
HTTP/1.1 200 OK 
Server: nginx/1.6.2 (Ubuntu) 
Date: Wed, 18 Nov 2015 09:17:11 GMT 
Content-Type: text/html; charset=utf-8 
Content-Length: 18422 
Connection: keep-alive 
Status: 200 OK 
... 

curl: (18) transfer closed with 18422 bytes remaining to read 

如此看來,我的老Rails的是不支持HEAD請求正常。

更新:我無法在我的流浪盒或登臺服務器上重現。只有生產上我能想到的是SSL。

0

看起來您的Uptime機器人正在發送一個錯誤值的標題。它應該發送內容長度頭值爲0(或根本不發送),但它發送與31842,這可能是錯誤的。

你可以直接到一些其他的http服務器,傾倒所有的標題,看看它爲什麼發送此或者只是改變你的正常運行時間機器人發送這個頭。