Include SocksProxyAgent inside while loop
To address error Socks5 proxy rejected connection - Failure
This commit is contained in:
parent
c610cacee4
commit
40bfc6bff3
@ -167,30 +167,30 @@ class Bisq {
|
|||||||
};
|
};
|
||||||
let retry = 0;
|
let retry = 0;
|
||||||
|
|
||||||
if (config.SOCKS5PROXY.ENABLED) {
|
|
||||||
const socksOptions: any = {
|
|
||||||
agentOptions: {
|
|
||||||
keepAlive: true,
|
|
||||||
},
|
|
||||||
hostname: config.SOCKS5PROXY.HOST,
|
|
||||||
port: config.SOCKS5PROXY.PORT
|
|
||||||
};
|
|
||||||
|
|
||||||
if (config.SOCKS5PROXY.USERNAME && config.SOCKS5PROXY.PASSWORD) {
|
|
||||||
socksOptions.username = config.SOCKS5PROXY.USERNAME;
|
|
||||||
socksOptions.password = config.SOCKS5PROXY.PASSWORD;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle proxy agent for onion addresses
|
|
||||||
if (isHTTP) {
|
|
||||||
axiosOptions.httpAgent = new SocksProxyAgent(socksOptions);
|
|
||||||
} else {
|
|
||||||
axiosOptions.httpsAgent = new SocksProxyAgent(socksOptions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while(retry < config.MEMPOOL.EXTERNAL_MAX_RETRY) {
|
while(retry < config.MEMPOOL.EXTERNAL_MAX_RETRY) {
|
||||||
try {
|
try {
|
||||||
|
if (config.SOCKS5PROXY.ENABLED) {
|
||||||
|
const socksOptions: any = {
|
||||||
|
agentOptions: {
|
||||||
|
keepAlive: true,
|
||||||
|
},
|
||||||
|
hostname: config.SOCKS5PROXY.HOST,
|
||||||
|
port: config.SOCKS5PROXY.PORT
|
||||||
|
};
|
||||||
|
|
||||||
|
if (config.SOCKS5PROXY.USERNAME && config.SOCKS5PROXY.PASSWORD) {
|
||||||
|
socksOptions.username = config.SOCKS5PROXY.USERNAME;
|
||||||
|
socksOptions.password = config.SOCKS5PROXY.PASSWORD;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle proxy agent for onion addresses
|
||||||
|
if (isHTTP) {
|
||||||
|
axiosOptions.httpAgent = new SocksProxyAgent(socksOptions);
|
||||||
|
} else {
|
||||||
|
axiosOptions.httpsAgent = new SocksProxyAgent(socksOptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const data: AxiosResponse = await axios.get(`${BISQ_URL}/trades/?market=bsq_btc`, axiosOptions);
|
const data: AxiosResponse = await axios.get(`${BISQ_URL}/trades/?market=bsq_btc`, axiosOptions);
|
||||||
if (data.statusText === 'error' || !data.data) {
|
if (data.statusText === 'error' || !data.data) {
|
||||||
throw new Error(`Could not fetch data from Bisq market, Error: ${data.status}`);
|
throw new Error(`Could not fetch data from Bisq market, Error: ${data.status}`);
|
||||||
|
@ -62,30 +62,30 @@ class FiatConversion {
|
|||||||
|
|
||||||
let retry = 0;
|
let retry = 0;
|
||||||
|
|
||||||
if (config.SOCKS5PROXY.ENABLED) {
|
|
||||||
let socksOptions: any = {
|
|
||||||
agentOptions: {
|
|
||||||
keepAlive: true,
|
|
||||||
},
|
|
||||||
hostname: config.SOCKS5PROXY.HOST,
|
|
||||||
port: config.SOCKS5PROXY.PORT
|
|
||||||
};
|
|
||||||
|
|
||||||
if (config.SOCKS5PROXY.USERNAME && config.SOCKS5PROXY.PASSWORD) {
|
|
||||||
socksOptions.username = config.SOCKS5PROXY.USERNAME;
|
|
||||||
socksOptions.password = config.SOCKS5PROXY.PASSWORD;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handle proxy agent for onion addresses
|
|
||||||
if (isHTTP) {
|
|
||||||
axiosOptions.httpAgent = new SocksProxyAgent(socksOptions);
|
|
||||||
} else {
|
|
||||||
axiosOptions.httpsAgent = new SocksProxyAgent(socksOptions);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while(retry < config.MEMPOOL.EXTERNAL_MAX_RETRY) {
|
while(retry < config.MEMPOOL.EXTERNAL_MAX_RETRY) {
|
||||||
try {
|
try {
|
||||||
|
if (config.SOCKS5PROXY.ENABLED) {
|
||||||
|
let socksOptions: any = {
|
||||||
|
agentOptions: {
|
||||||
|
keepAlive: true,
|
||||||
|
},
|
||||||
|
hostname: config.SOCKS5PROXY.HOST,
|
||||||
|
port: config.SOCKS5PROXY.PORT
|
||||||
|
};
|
||||||
|
|
||||||
|
if (config.SOCKS5PROXY.USERNAME && config.SOCKS5PROXY.PASSWORD) {
|
||||||
|
socksOptions.username = config.SOCKS5PROXY.USERNAME;
|
||||||
|
socksOptions.password = config.SOCKS5PROXY.PASSWORD;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle proxy agent for onion addresses
|
||||||
|
if (isHTTP) {
|
||||||
|
axiosOptions.httpAgent = new SocksProxyAgent(socksOptions);
|
||||||
|
} else {
|
||||||
|
axiosOptions.httpsAgent = new SocksProxyAgent(socksOptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
logger.debug('Querying currency rates service...');
|
logger.debug('Querying currency rates service...');
|
||||||
|
|
||||||
const response: AxiosResponse = await axios.get(`${fiatConversionUrl}`, axiosOptions);
|
const response: AxiosResponse = await axios.get(`${fiatConversionUrl}`, axiosOptions);
|
||||||
|
@ -129,25 +129,25 @@ class PoolsUpdater {
|
|||||||
};
|
};
|
||||||
let retry = 0;
|
let retry = 0;
|
||||||
|
|
||||||
if (config.SOCKS5PROXY.ENABLED) {
|
|
||||||
const socksOptions: any = {
|
|
||||||
agentOptions: {
|
|
||||||
keepAlive: true,
|
|
||||||
},
|
|
||||||
hostname: config.SOCKS5PROXY.HOST,
|
|
||||||
port: config.SOCKS5PROXY.PORT
|
|
||||||
};
|
|
||||||
|
|
||||||
if (config.SOCKS5PROXY.USERNAME && config.SOCKS5PROXY.PASSWORD) {
|
|
||||||
socksOptions.username = config.SOCKS5PROXY.USERNAME;
|
|
||||||
socksOptions.password = config.SOCKS5PROXY.PASSWORD;
|
|
||||||
}
|
|
||||||
|
|
||||||
axiosOptions.httpsAgent = new SocksProxyAgent(socksOptions);
|
|
||||||
}
|
|
||||||
|
|
||||||
while(retry < config.MEMPOOL.EXTERNAL_MAX_RETRY) {
|
while(retry < config.MEMPOOL.EXTERNAL_MAX_RETRY) {
|
||||||
try {
|
try {
|
||||||
|
if (config.SOCKS5PROXY.ENABLED) {
|
||||||
|
const socksOptions: any = {
|
||||||
|
agentOptions: {
|
||||||
|
keepAlive: true,
|
||||||
|
},
|
||||||
|
hostname: config.SOCKS5PROXY.HOST,
|
||||||
|
port: config.SOCKS5PROXY.PORT
|
||||||
|
};
|
||||||
|
|
||||||
|
if (config.SOCKS5PROXY.USERNAME && config.SOCKS5PROXY.PASSWORD) {
|
||||||
|
socksOptions.username = config.SOCKS5PROXY.USERNAME;
|
||||||
|
socksOptions.password = config.SOCKS5PROXY.PASSWORD;
|
||||||
|
}
|
||||||
|
|
||||||
|
axiosOptions.httpsAgent = new SocksProxyAgent(socksOptions);
|
||||||
|
}
|
||||||
|
|
||||||
const data: AxiosResponse = await axios.get(path, axiosOptions);
|
const data: AxiosResponse = await axios.get(path, axiosOptions);
|
||||||
if (data.statusText === 'error' || !data.data) {
|
if (data.statusText === 'error' || !data.data) {
|
||||||
throw new Error(`Could not fetch data from Github, Error: ${data.status}`);
|
throw new Error(`Could not fetch data from Github, Error: ${data.status}`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user