Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor - Connection Timeout. No heartbeat received

Tags:

I get the following error:

Connection timeout. No heartbeat received.

When accessing my meteor app (http://127.0.0.1:3000). The application has been moved over to a new pc with the same code base - and the server runs fine with no errors, and I can access the mongodb. What would cause the above error?

The problem seems to occur when the collection is larger. however I have it running on another computer which loads the collections instantaneously. The connection to to sock takes over a minute and grows in size, before finally failing:

enter image description hereenter image description here

like image 693
rickyduck Avatar asked Jul 19 '13 09:07

rickyduck


1 Answers

Meteor's DDP implements Sockjs's Heartbeats used for long-polling. This is probably due to DDP Heartbeat's timeout default of 15s. If you access a large amount of data and it takes a lot of time, in your case, 1 minute, DDP will time out after being blocked long enough by the operation to prevent connections being closed by proxies (which can be worse), and then try to reconnect again. This can go on forever and you may never get the process completed.

You can try hypothetically disconnecting and reconnecting in short amount of time before DDP closes the connection, and divide the database access into shorter continuous processes which you can pick up on each iteration and see if the problem persists:

// 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
}

However, when disconnected all live-updating will stop as well, but explicitly reconnecting might make up for smaller blocking.

See a discussion on this issue on Google groupand Meteor Hackpad

like image 165
Pandemonium Avatar answered Oct 16 '22 07:10

Pandemonium