node-xcs
node-xcs copied to clipboard
UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'write' of null
When having network problems, I received this Warning, though when network had recovered the connection restored without problems.
on "line 362", I'm periodically sending testing messages to FCM just to check connection:
// проверка соединения с FCM:
setInterval(function () {
let from = "111222333";
let message = new Message(from + "_ack").priority("high").dryRun(true)
.addData("messageId", from)
.deliveryReceiptRequested(true)
.build();
logger.info('Check connection... ' + new Date());
xcs.sendNoRetry(message, from, function (result) {
if (result.getError()) {
if (result.getError() === 'BAD_REGISTRATION')
logger.info("Check connection ok");
else
logger.error("Check connection ERROR! " + result.getError());
} else {
logger.info(`Check connection ${senderXcs.name} message sent: #` + result.getMessageId());
}
}); // Messages received from client (excluding receipts)
}, 120000);