法拉第(Ruby)超时错误
我正试图使用法拉第将路由a(Sinatra应用程序)中生成的一个小有效负载放到路由B。因此,代码基本上如下所示:法拉第(Ruby)超时错误,ruby,faraday,Ruby,Faraday,我正试图使用法拉第将路由a(Sinatra应用程序)中生成的一个小有效负载放到路由B。因此,代码基本上如下所示: post "/routeA" do foo.save foo_id = foo.id conn = Faraday.new(:url => "http://localhost:3001/routeB" ) do |builder| builder.request :url_encoded builder.response :logger bu
post "/routeA" do
foo.save
foo_id = foo.id
conn = Faraday.new(:url => "http://localhost:3001/routeB" ) do |builder|
builder.request :url_encoded
builder.response :logger
builder.adapter :net_http
end
resp = conn.put do |req|
req.url '/routeB'
req.headers['Content-Type'] = 'application/json'
req.body = {:id => foo_id }.to_json
req.options = {
#:timeout => 5, # see below, these aren't the problem
#:open_timeout => 2
}
end
# never gets here b/c Timeout error always thrown
STDERR.puts resp.body
end
put "/routeB" do
# for test purposes just log output
STDERR.puts request.body.read.to_s.inspect
status 202
body '{"Ok"}'
end
问题是它总是抛出一个超时错误(我运行时没有超时选项,上面显示的选项->相同的结果)。但是,日志显示请求正在通过:
I, [2012-03-24T16:56:13.241329 #17673] INFO -- : put http://localhost:3001/routeB
D, [2012-03-24T16:56:13.241427 #17673] DEBUG -- request: Content-Type: "application/json"
#<Faraday::Error::TimeoutError>
DEBUG - POST (60.7987ms) /routeA - 500 Internal Server Error
"{\"id\":7}"
DEBUG - PUT (0.0117ms) /routeB - 202 Accepted
I[2012-03-24T16:56:13.241329#17673]信息--:puthttp://localhost:3001/routeB
D、 调试--请求:内容类型:“application/json”
#
调试-POST(60.7987ms)/routeA-500内部服务器错误
“{\'id\':7}”
调试-输入(0.0117ms)/routeB-202已接受
不确定如何通过超时错误?如有任何见解,将不胜感激。谢谢。问题是,在当前请求完成之前,应用程序无法响应其他请求。也就是说,当您在
/routeB
上发出PUT请求时,应用程序得到了该请求,并且正在等待当前请求(/routeA
)完成。但是请求不会完成,因为它正在等待从/routeB
获取响应。我认为这就是导致超时错误的原因