【发布时间】:2016-09-05 20:06:17
【问题描述】:
我正在测试一些高速公路代码,其中包括 onopen 事件和 onclose 事件。我注意到更新会停止,但是我的代码会继续运行,所以我怀疑连接丢失了。我将 onclose 事件更新为按以下方式存在:
connection.onclose = (reason, details) => {
console.log("REASON", reason);
console.log("DETAILS", details);
reject(reason);
process.exit();
};
当连接丢失时,我现在得到:
REASON lost
DETAILS { reason: null,
message: null,
retry_delay: 1.3305311206405022,
retry_count: 1,
will_retry: true }
我是否可以响应此事件并重新建立连接,或者我的“process.exit()”行是否会自动阻止这种情况发生?
【问题讨论】: