oortcloud / node-ddp-client

A callback style DDP (Meteor's Distributed Data Protocol) node client.
Other
263 stars 80 forks source link

Need help to handle disconnection #61

Open fuatsengul opened 9 years ago

fuatsengul commented 9 years ago

Hi there I've handled socket-error and socket-close events with your sample code but when I manually disconnect the client (like removing the ethernet cable) those handlers never goes in action. If I shutted down the server, I see socket-close is works well. Does it flashes any simple solution on your mind? Any help will be appreciated :) Thanks :)

ddpclient.on('socket-close', function(code, message) {
  console.log("Close: %s %s", code, message);
});

ddpclient.on('socket-error', function(error) {
  console.log("Error: %j", error);
});
bsocius commented 9 years ago

fuatsengul,

Did you already find a solution to your problem?

fuatsengul commented 9 years ago

Hello Bsocius,

Actually I did not. I made a workaround by setting a timer to check the connection at every 5 seconds and when connection was lost, it sets another timer to retry connecting to the server.

vsivsi commented 9 years ago

Is this an issue with the ddp-client, or with faye-websocket on top of which the ddp-client is built?

emgee3 commented 9 years ago

I think the only actual issue is we (I) only implemented responding to heartbeats in the ddp v2 spec.

clvLabs commented 8 years ago

Hi all!

I'm having the same issue as @fuatsengul: If I disconnect the Ethernet cable while a DDP client connection is alive but not sending anything the disconnection goes unnoticed.

I've forked the project and will give it a try with the client heartbeat sending. ...

fuatsengul commented 8 years ago

Hello @clvLabs, If you haven't done it yet, I suggest to take a look forked repos. There's one that I liked it much more, (xolvio's) which it has promise support for method calls, so you can easily throw timeout exceptions and manage your connectivity state with this events.

Btw, hope those forks gets merged soon.