gpt4 book ai didi

node.js - Meteor - 连接超时。没有收到心跳

转载 作者:IT老高 更新时间:2023-10-28 13:05:41 26 4
gpt4 key购买 nike

我收到以下错误:

Connection timeout. No heartbeat received.

访问我的 meteor 应用程序时 (http://127.0.0.1:3000)。该应用程序已移至具有相同代码库的新 PC - 服务器运行良好且没有错误,我可以访问 mongodb。什么会导致上述错误?

当集合较大时,似乎会出现问题。但是我让它在另一台计算机上运行,​​它会立即加载集合。与 sock 的连接需要一分钟多的时间,并在最终失败之前逐渐增大:

enter image description here enter image description here

最佳答案

Meteor 的 DDP 实现了用于长轮询的 Sockjs 的心跳。这可能是由于 DDP Heartbeat 的超时默认值为 15 秒。如果您访问大量数据并且需要很长时间(在您的情况下为 1 分钟),DDP 将在被操作阻止足够长的时间以防止连接被代理关闭(这可能更糟)后超时,并且然后尝试重新连接。这可能会一直持续下去,您可能永远无法完成该过程。

您可以假设在 DDP 关闭连接之前的短时间内断开连接并重新连接,并将数据库访问划分为较短的连续过程,您可以在每次迭代中获取这些过程并查看问题是否仍然存在:

// while cursorCount <= data {
Meteor.onConnection(dbOp);
Meteor.setTimeout(this.disconnect, 1500); // Adjust timeout here
Meteor.reconnect();
cursorCount++;
}

func dbOp(cursorCount) {
// database operation here
// pick up the operation at cursorCount where last .disconnect() left off
}

但是,当断开连接时,所有实时更新也会停止,但明确地重新连接可能会弥补较小的阻塞。

Google group 上查看有关此问题的讨论和 Meteor Hackpad

关于node.js - Meteor - 连接超时。没有收到心跳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17743244/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com