simpleddp icon indicating copy to clipboard operation
simpleddp copied to clipboard

Connecting to non-existent / listening endpoint

Open ruohki opened this issue 4 years ago • 4 comments

As the title states,

how to deal when trying to connect to a non-answering endpoint? the connect promise will never resolve no disconnect or error gets fired?

ruohki avatar Feb 29 '20 16:02 ruohki

Hello, by default - yes. But you can use maxTimeout option (in ms)(https://gregivy.github.io/simpleddp/simpleDDP.html) like this:

let opts = {
    endpoint: "ws://someserver.com/websocket",
    SocketConstructor: ws,
    reconnectInterval: 5000,
    maxTimeout: 15000
};
const server = new simpleDDP(opts);

Gregivy avatar Feb 29 '20 22:02 Gregivy

Hello Gregivy, I'm having similar issue, I think we need a graceful way to handle that error, settings the maxTimeout doesn't throw an error.

aogaili avatar Mar 13 '20 20:03 aogaili

The maxtTimeout does trigger on method calls so it does the trick.

Thanks @Gregivy for this great library.

aogaili avatar Mar 14 '20 18:03 aogaili

Thank you @aliogaili, however I am going to add maxTimeout for .connect() method, it is a good idea.

Gregivy avatar Apr 08 '20 18:04 Gregivy