以下代码将始终以#<Errno::ECONNRESET: Connection reset by peer - SSL_connect>错误消息结束。
它可能会在 5 秒或 30 分钟后失败。
require 'net/https'
http = Net::HTTP.new('newproduct.zendesk.com', 443)
http.use_ssl = true
req = Net::HTTP::Head.new('/')
while true
res = http.start { http.request(req) }
end
Run Code Online (Sandbox Code Playgroud)
在 Mac 和 Linux 上运行时都会发生这种情况,并导致我的批处理作业失败。
看起来很难调试,但是有什么我应该注意的吗?
ECONNRESET 是一个套接字错误,指示连接的另一端(在本例中为 Zendesk)突然终止了连接。可能是他们那边的网络错误,或者是您和 Zendesk 之间的某个地方的网络错误。
在使用 Zendesk gem for ruby 时,我每隔几百次调用就会看到同样的错误。
对我有用的是挽救这些错误,将不成功的 API 调用的参数存储在数组(或文件或 Redis)中,然后重试。
| 归档时间: |
|
| 查看次数: |
11001 次 |
| 最近记录: |