Reputation: 1224
I have some autobahn code I am testing that includes both an onopen event and an onclose event. I had noticed by updates would cease however my code would continue to run so I suspected the connection was being lost. I updated the onclose event to exist as per:
connection.onclose = (reason, details) => {
console.log("REASON", reason);
console.log("DETAILS", details);
reject(reason);
process.exit();
};
When the connection is lost I now get:
REASON lost
DETAILS { reason: null,
message: null,
retry_delay: 1.3305311206405022,
retry_count: 1,
will_retry: true }
Is there anyway I can respond to this event and re-establish the connection or does my "process.exit()" line stop this from happening automatically?
Upvotes: 1
Views: 1207
Reputation: 2445
Autobahn|JS does automatic reconnects (which are configurable - see http://autobahn.ws/js/reference.html#connection-options).
You can, in principle, also call the connection's 'open' method again from the close handler, e.g. if you want custom reconnect logic.
Your closing code in the 'onclose' handler shuts down the entire process, so that no automatic reconnect is attempted.
Upvotes: 2