Include SocksProxyAgent inside while loop

To address error Socks5 proxy rejected connection - Failure
This commit is contained in:
Ayanami 2022-05-23 20:05:32 +09:00
parent c610cacee4
commit 40bfc6bff3
No known key found for this signature in database
GPG Key ID: 0CABDF03077D92E4
3 changed files with 61 additions and 61 deletions

View File

@ -167,6 +167,8 @@ class Bisq {
}; };
let retry = 0; let retry = 0;
while(retry < config.MEMPOOL.EXTERNAL_MAX_RETRY) {
try {
if (config.SOCKS5PROXY.ENABLED) { if (config.SOCKS5PROXY.ENABLED) {
const socksOptions: any = { const socksOptions: any = {
agentOptions: { agentOptions: {
@ -189,8 +191,6 @@ class Bisq {
} }
} }
while(retry < config.MEMPOOL.EXTERNAL_MAX_RETRY) {
try {
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}`);

View File

@ -62,6 +62,8 @@ class FiatConversion {
let retry = 0; let retry = 0;
while(retry < config.MEMPOOL.EXTERNAL_MAX_RETRY) {
try {
if (config.SOCKS5PROXY.ENABLED) { if (config.SOCKS5PROXY.ENABLED) {
let socksOptions: any = { let socksOptions: any = {
agentOptions: { agentOptions: {
@ -84,8 +86,6 @@ class FiatConversion {
} }
} }
while(retry < config.MEMPOOL.EXTERNAL_MAX_RETRY) {
try {
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);

View File

@ -129,6 +129,8 @@ class PoolsUpdater {
}; };
let retry = 0; let retry = 0;
while(retry < config.MEMPOOL.EXTERNAL_MAX_RETRY) {
try {
if (config.SOCKS5PROXY.ENABLED) { if (config.SOCKS5PROXY.ENABLED) {
const socksOptions: any = { const socksOptions: any = {
agentOptions: { agentOptions: {
@ -146,8 +148,6 @@ class PoolsUpdater {
axiosOptions.httpsAgent = new SocksProxyAgent(socksOptions); axiosOptions.httpsAgent = new SocksProxyAgent(socksOptions);
} }
while(retry < config.MEMPOOL.EXTERNAL_MAX_RETRY) {
try {
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}`);