Rpj*_*Rpj 5 ruby-on-rails rest-client
我使用的是最新版本的rest-client gem,在外部访问时我看到很多RestClient :: ServerBrokeConnection错误,我该如何处理呢?
以下呼叫失败
response = RestClient::Request.execute(method: :post, url: url, headers: headers, "Content-Type" => "application/x-www-form-urlencoded")
Run Code Online (Sandbox Code Playgroud)
当服务器断开与客户端的连接时,会发生此错误.您可以决定重试请求,或者只是冒错误让用户知道并处理它.
因为rest-client如何处理这里所示的断开连接,所以你所能做的就是从中拯救它
begin
response = RestClient::Request.execute(method: :post, url: url, headers: headers, "Content-Type" => "application/x-www-form-urlencoded")
rescue RestClient::ServerBrokeConnection
// retry or do something
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1995 次 |
| 最近记录: |