Heroku 偶尔返回找不到“主机名”

Mic*_*ren 5 ruby-on-rails heroku nserror ios

我正在创建一个在 Heroku 上使用 Rails API 后端的 iOS 应用程序。定期(每 20 个 API 调用一次),找不到 heroku。返回以下 NSError:

Error Domain=NSURLErrorDomain Code=-1003 "A server with the specified hostname could not be found." UserInfo=0x755ce00 {NSErrorFailingURLStringKey=https://xxx.herokuapp.com/api/v1/matchups, NSErrorFailingURLKey=https://xxx.herokuapp.com/api/v1/matchups, NSLocalizedDescription=A server with the specified hostname could not be found., NSUnderlyingError=0x71ca730 "A server with the specified hostname could not be found."
Run Code Online (Sandbox Code Playgroud)

Pau*_*lgo 0

您似乎受到了 Dyno 睡眠行为的影响。请检查此文档,特别是Dyno 睡眠部分,并确保您理解它。此外,还有多种方法可以让应用程序保持运行状态,例如定期对网站执行 ping 操作。

另一个选择是 DNS,在您的计算机上创建一个 Ad-Hoc 网络并将您的 iPhone 连接到该网络。使用wireshark进行网络捕获并分析DNS和HTTP响应。

  • 我很欣赏您的回复,但这不是动态睡眠问题。我的 iOS 应用程序上有一个刷新按钮,我可以在 1 分钟内重复点击刷新约 15-20 次,偶尔,其中一次刷新会导致主机名未找到错误。有什么想法吗? (2认同)