LivePersonInc / node-agent-sdk

LivePerson Agent Messaging SDK for NodeJS
MIT License
49 stars 78 forks source link

Disconnects happening. Heartbeat ping/pong mechanism not implemented. #104

Closed lp-hong closed 4 years ago

lp-hong commented 4 years ago

Bot is experiencing disconnects from Live Engage without the websocket actually being closed. The onClose event never fires. As per WS Library broken connections without client/server knowing can happen.

There is no heartbeat ping/pong mechanism that I see implemented. For it to be properly implemented, WS pong event needs to have a callback.

From WS library to implement properly: https://github.com/websockets/ws#how-to-detect-and-close-broken-connections

I have a pull request ready.

lp-hong commented 4 years ago

Okay I relooked at the code and ws library recommendations on broken connections. It looks like the ping method in Transport emits an error if the ping errors out in a try/catch block. It doesn't wait for the pong. The ws library recommends to terminate the web socket. Does that mean Agent bots are supposed to terminate the websocket on any error?

WS library or spec is unclear. In any case, I think ping/pong is better as it it's in the spec?

lp-hong commented 4 years ago

Upon further investigation, getClock is working well enough