为什么当我停止并重新启动 mongod 服务时会出现应用程序错误

发布于 2024-11-07 01:57:50 字数 502 浏览 8 评论 0原文

如果我取消并在默认端口上重新启动 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

甜警司 2024-11-14 01:57:50

Mongoid 创建与 MongoDB 进程的连接,然后出于性能原因保留该连接。如果服务器宕机,服务器端的连接就会中断,客户端将无法再发送请求。

在您的 Mongoid 配置中,您可以将连接配置为可重试,以便失败的连接将被即使失败也会重试。

max_retries_on_connection_failure [2]

方括号中的数字是引发异常之前重试的次数(每次尝试之间有半秒的间隔)。

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.

max_retries_on_connection_failure [2]

The number in square brackets is the number of times to retry (with half second gap between each try) before raising an exception.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文