@@ -159,9 +159,7 @@ export class ElectrumExplorer implements Explorer {
159159 client : 'bitcoinerlab' ,
160160 version : '1.4'
161161 } ,
162- //don't let it handle auto-reconnect. Handling reconnection here
163- //in #pingInterval and/or from the libraries using @bitcoinerlab /explorer
164- { maxRetry : 0 , callback : null } ,
162+ { maxRetry : 1000 , callback : null } ,
165163 this . #timeout
166164 ) ;
167165 this . #client. subscribe . on (
@@ -190,7 +188,7 @@ export class ElectrumExplorer implements Explorer {
190188 ) ;
191189 }
192190
193- // Ping every minute to keep connection alive.
191+ // Ping every few seconds to keep connection alive.
194192 // This function will never throw since it cannot be handled
195193 // In case of connection errors, users will get them on any next function
196194 // call
@@ -202,23 +200,23 @@ export class ElectrumExplorer implements Explorer {
202200 } catch ( error : unknown ) {
203201 shouldReconnect = true ;
204202 console . warn (
205- 'Closing connection and reconnecting in 0.5s after ping error:' ,
203+ 'Closing connection and reconnecting in 1s after ping error:' ,
206204 getErrorMsg ( error )
207205 ) ;
208206 }
209207 if ( shouldReconnect ) {
210208 try {
211209 if ( await this . isConnected ( false ) ) await this . close ( ) ; //hide possible socket errors
212- await new Promise ( resolve => setTimeout ( resolve , 500 ) ) ;
210+ await new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ;
213211 await this . connect ( ) ;
214212 } catch ( error ) {
215213 console . warn (
216- 'Error while reconnecting connection while pinging the electrum server. ' ,
214+ 'Error while reconnecting during interval pinging: ' ,
217215 getErrorMsg ( error )
218216 ) ;
219217 }
220218 }
221- } , 60 * 1000 ) ; // 60 * 1000 ms = 1 minute
219+ } , 14 * 1000 ) ; // 14 * 1000 ms = 14 seconds
222220 }
223221
224222 /**
0 commit comments