guness / node-xcs

NodeJS implementation of Google's XMPP Connection Server
BSD 2-Clause "Simplified" License
38 stars 23 forks source link

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'write' of null #35

Open freerider7777 opened 2 years ago

freerider7777 commented 2 years ago

When having network problems, I received this Warning, though when network had recovered the connection restored without problems.

image

on "line 362", I'm periodically sending testing messages to FCM just to check connection:

image

// проверка соединения с 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);