mirror of
https://github.com/fullstack-cash/bch-api.git
synced 2026-09-22 01:02:05 -07:00
fix(electrumx): Automatically reconnecting when Electrumx disconnects
This commit is contained in:
@@ -79,6 +79,21 @@ class Electrum {
|
||||
// Set the connection flag.
|
||||
_this.isReady = true
|
||||
|
||||
// Periodically check the connection. If it's not connected, attempt to
|
||||
// reconnect.
|
||||
setInterval(async function () {
|
||||
const status = _this.electrumx.connection.status
|
||||
// console.log(`Electrumx status: ${status}`)
|
||||
|
||||
// 1 = connected. If we're not connected, attemp to reconnect.
|
||||
if (status !== 1) {
|
||||
wlogger.info(`Electrumx not connectes. Status: ${status}`)
|
||||
wlogger.info(`Attempting to reconnect...`)
|
||||
await _this.electrumx.connect()
|
||||
wlogger.info(`...reconnected.`)
|
||||
}
|
||||
}, 30000)
|
||||
|
||||
console.log('...Successfully connected to ElectrumX server.')
|
||||
|
||||
// console.log(`_this.isReady: ${_this.isReady}`)
|
||||
|
||||
Reference in New Issue
Block a user