[esplora] print log when retrying unix socket - don't fallback to tcp socket on ETIMEDOUT
This commit is contained in:
parent
66109afb0d
commit
db27e5a92c
@ -29,9 +29,10 @@ class ElectrsApi implements AbstractBitcoinApi {
|
|||||||
|
|
||||||
fallbackToTcpSocket() {
|
fallbackToTcpSocket() {
|
||||||
if (!this.unixSocketRetryTimeout) {
|
if (!this.unixSocketRetryTimeout) {
|
||||||
logger.err(`Unable to connect to esplora unix socket. Falling back to tcp socket. Retrying unix socket in ${config.ESPLORA.RETRY_UNIX_SOCKET_AFTER} seconds`);
|
logger.err(`Unable to connect to esplora unix socket. Falling back to tcp socket. Retrying unix socket in ${config.ESPLORA.RETRY_UNIX_SOCKET_AFTER / 1000} seconds`);
|
||||||
// Retry the unix socket after a few seconds
|
// Retry the unix socket after a few seconds
|
||||||
this.unixSocketRetryTimeout = setTimeout(() => {
|
this.unixSocketRetryTimeout = setTimeout(() => {
|
||||||
|
logger.info(`Retrying to use unix socket for esplora now (applied for the next query)`);
|
||||||
this.activeAxiosConfig = this.axiosConfigWithUnixSocket;
|
this.activeAxiosConfig = this.axiosConfigWithUnixSocket;
|
||||||
}, config.ESPLORA.RETRY_UNIX_SOCKET_AFTER);
|
}, config.ESPLORA.RETRY_UNIX_SOCKET_AFTER);
|
||||||
}
|
}
|
||||||
@ -44,7 +45,7 @@ class ElectrsApi implements AbstractBitcoinApi {
|
|||||||
return axiosConnection.get<T>(url, { ...this.activeAxiosConfig, responseType: responseType })
|
return axiosConnection.get<T>(url, { ...this.activeAxiosConfig, responseType: responseType })
|
||||||
.then((response) => response.data)
|
.then((response) => response.data)
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
if (e?.code === 'ECONNREFUSED' || e?.code === 'ETIMEDOUT') {
|
if (e?.code === 'ECONNREFUSED') {
|
||||||
this.fallbackToTcpSocket();
|
this.fallbackToTcpSocket();
|
||||||
// Retry immediately
|
// Retry immediately
|
||||||
return axiosConnection.get<T>(url, this.activeAxiosConfig)
|
return axiosConnection.get<T>(url, this.activeAxiosConfig)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user