为什么当我停止并重新启动 mongod 服务时会出现应用程序错误
如果我取消并在默认端口上重新启动 mongodb,我可以正常重新连接并且没有任何问题。
当我在 27018
端口上执行此操作时,它似乎在我的 bash 窗口中重新连接,并且在重新启动结束时收到此语句:
initandlisten] waiting for connections on port 27018
websvr] web admin interface listening on port 28018
但是当我运行我的应用程序时,我收到如下错误
Operation failed with the following exception: connection closed
:
Operation failed with the following exception: Broken pipe - send(2)
:10:in `synchronize'
If I cancel and restart my mongodb on the default port, I reconnect fine and there aren't any problems.
When I do so on my 27018
port, it seems to reconnect in my bash window and I get this statement at the end of the restart:
initandlisten] waiting for connections on port 27018
websvr] web admin interface listening on port 28018
but when I run my app I get errors like
Operation failed with the following exception: connection closed
and
Operation failed with the following exception: Broken pipe - send(2)
:10:in `synchronize'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Mongoid 创建与 MongoDB 进程的连接,然后出于性能原因保留该连接。如果服务器宕机,服务器端的连接就会中断,客户端将无法再发送请求。
在您的 Mongoid 配置中,您可以将连接配置为可重试,以便失败的连接将被即使失败也会重试。
方括号中的数字是引发异常之前重试的次数(每次尝试之间有半秒的间隔)。
Mongoid creates a connection to the MongoDB process and then keeps this around for performance reasons. If the server goes down the connection is broken at the server end and the client can no longer send requests.
In your Mongoid configuration you can configure the connection to be retriable, so that failed connections will be retried in the even of failure.
The number in square brackets is the number of times to retry (with half second gap between each try) before raising an exception.