Merge pull request #138 from shocknet/bug/socket-reconnection

Reconnect socket after 30 seconds on connection drop
This commit is contained in:
CapDog 2020-08-04 14:45:45 -04:00 committed by GitHub
commit a6c4745097

View file

@ -131,7 +131,10 @@ module.exports = (
logger.warn('New invoice stream status:', status) logger.warn('New invoice stream status:', status)
if (status.code === 14) { if (status.code === 14) {
// Prevents call stack overflow exceptions // Prevents call stack overflow exceptions
process.nextTick(() => onNewInvoice(socket)) logger.error(
'[event:invoice:new] LND disconnected, sockets reconnecting in 30 seconds...'
)
process.nextTick(() => setTimeout(() => onNewInvoice(socket), 30000))
} }
}) })
} }
@ -154,7 +157,12 @@ module.exports = (
stream.on('status', status => { stream.on('status', status => {
logger.error('New invoice stream status:', status) logger.error('New invoice stream status:', status)
if (status.code === 14) { if (status.code === 14) {
process.nextTick(() => onNewTransaction(socket)) logger.error(
'[event:transaction:new] LND disconnected, sockets reconnecting in 30 seconds...'
)
process.nextTick(() =>
setTimeout(() => onNewTransaction(socket), 30000)
)
} }
}) })
} }