我在rails中有一个方法可以将发布请求发送到第三方API。代码类似于以下内容:
data = HTTParty.post("url",
:headers=> {'Content-Type' => 'application/json'},
:body=> { update => true, first_name => "name" }
)
这样,在一分钟后,该过程终止,并出现以下错误。
<Net::HTTPGatewayTimeOut 504 GATEWAY_TIMEOUT readbody=true>
答案 0 :(得分:7)
设置默认值:
module HTTParty
default_timeout your_preferred_timeout
end
或通过以下方式单独设置:
data = HTTParty.post("url",
headers: {"Content-Type" => "application/json"},
body: {update => true, first_name => "name"},
timeout: your_preferred_timeout
)