0

I try fo fetch pair prices on uniswap, sushiswap and quickswap. Everything works for like one minute. But then I get disconnected I think and I don't know what I have to change. I setup a server like this:

// SERVER CONFIG
const PORT = process.env.PORT || 5000;
const app = express();
const server = http
  .createServer(app)
  .listen(PORT, () => console.log(`Listening on ${PORT}`));

and then run the main() function all 3 seconds:

const POLLING_INTERVAL = process.env.POLLING_INTERVAL || 3000; // 3 Seconds
priceMonitor = setInterval(async () => {
  await main();
}, POLLING_INTERVAL);

My main() function looks like this:

async function main() {
var amountOut_v3 = await getPriceOnUniV3(
    token_Address_matic,
    token_Address_weth,
    amount_wei
  );
var new_amount_in = ethers.utils.parseUnits(amountOut_v3.toString(), 18);

  var amountOut_v2 = await getPriceOnUniV2(
    token_Address_weth,
    token_Address_matic,
    new_amount_in,
    quickswap_router
  );

  const amountOut_matic_v2_uni_to_quick = Math.round(amountOut_v2 * 100) / 100;
console.log("------------------------------------------------------");
    console.log(
      `Route 1: MATIC -> WETH (Uniswap V3) and WETH -> MATIC (Quickswap): ${amount} to ${amountOut_matic_v2_uni_to_quick}`
    );
}

After 30 seconds to one minute I get the following error:

c:\Users\user\price_check\node_modules\@ethersproject\logger\lib\index.js:238
        var error = new Error(message);
                    ^

Error: missing revert data in call exception; Transaction reverted without a reason string [ See: https://links.ethers.org/v5-errors-CALL_EXCEPTION ] (data="0x", transaction={"to":"0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506","data":"0xd06ca61f000000000000000000000000000000000000000000000002a0cdbe9e66eed7d7000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf1270","accessList":null}, error={"reason":"missing response","code":"SERVER_ERROR","requestBody":"{\"method\":\"eth_call\",\"params\":[{\"to\":\"0x1b02da8cb0d097eb8d57a175b88c7d8b47997506\",\"data\":\"0xd06ca61f000000000000000000000000000000000000000000000002a0cdbe9e66eed7d7000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf1270\"},\"latest\"],\"id\":178,\"jsonrpc\":\"2.0\"}","requestMethod":"POST","serverError":{"errno":-4039,"code":"ETIMEDOUT","syscall":"connect","address":"104.18.11.116","port":443},"url":"https://polygon-rpc.com/"}, code=CALL_EXCEPTION, version=providers/5.7.0)
    at Logger.makeError (c:\Users\user\price_check\node_modules\@ethersproject\logger\lib\index.js:238:21)
    at Logger.throwError (c:\Users\user\price_check\node_modules\@ethersproject\logger\lib\index.js:247:20)
    at checkError (c:\Users\user\price_check\node_modules\@ethersproject\providers\lib\json-rpc-provider.js:108:16)
    at JsonRpcProvider.<anonymous> (c:\Users\user\price_check\node_modules\@ethersproject\providers\lib\json-rpc-provider.js:751:47)
    at step (c:\Users\user\price_check\node_modules\@ethersproject\providers\lib\json-rpc-provider.js:48:23)
    at Object.throw (c:\Users\user\price_check\node_modules\@ethersproject\providers\lib\json-rpc-provider.js:29:53)
    at rejected (c:\Users\user\price_check\node_modules\@ethersproject\providers\lib\json-rpc-provider.js:21:65)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  reason: 'missing revert data in call exception; Transaction reverted without a reason string',
  code: 'CALL_EXCEPTION',
  data: '0x',
  transaction: {
    to: '0x1b02dA8Cb0d097eB8D57A175b88c7D8b47997506',
    data: '0xd06ca61f000000000000000000000000000000000000000000000002a0cdbe9e66eed7d7000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf1270',
    accessList: null
  },
  error: Error: missing response (requestBody="{\"method\":\"eth_call\",\"params\":[{\"to\":\"0x1b02da8cb0d097eb8d57a175b88c7d8b47997506\",\"data\":\"0xd06ca61f000000000000000000000000000000000000000000000002a0cdbe9e66eed7d7000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf1270\"},\"latest\"],\"id\":178,\"jsonrpc\":\"2.0\"}", requestMethod="POST", serverError={"errno":-4039,"code":"ETIMEDOUT","syscall":"connect","address":"104.18.11.116","port":443}, url="https://polygon-rpc.com/", code=SERVER_ERROR, version=web/5.7.0)
      at Logger.makeError (c:\Users\user\price_check\node_modules\@ethersproject\logger\lib\index.js:238:21)
      at Logger.throwError (c:\Users\user\price_check\node_modules\@ethersproject\logger\lib\index.js:247:20)
      at c:\Users\user\price_check\node_modules\@ethersproject\web\lib\index.js:255:36
      at step (c:\Users\user\price_check\node_modules\@ethersproject\web\lib\index.js:33:23)
      at Object.throw (c:\Users\user\price_check\node_modules\@ethersproject\web\lib\index.js:14:53)
      at rejected (c:\Users\user\price_check\node_modules\@ethersproject\web\lib\index.js:6:65)
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (node:internal/process/task_queues:96:5) {
    reason: 'missing response',
    code: 'SERVER_ERROR',
    requestBody: '{"method":"eth_call","params":[{"to":"0x1b02da8cb0d097eb8d57a175b88c7d8b47997506","data":"0xd06ca61f000000000000000000000000000000000000000000000002a0cdbe9e66eed7d7000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000020000000000000000000000007ceb23fd6bc0add59e62ac25578270cff1b9f6190000000000000000000000000d500b1d8e8ef31e21c99d1db9a6444d3adf1270"},"latest"],"id":178,"jsonrpc":"2.0"}',
    requestMethod: 'POST',
    serverError: Error: connect ETIMEDOUT 104.18.11.116:443
        at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1187:16) {
      errno: -4039,
      code: 'ETIMEDOUT',
      syscall: 'connect',
      address: '104.18.11.116',
      port: 443
    },
    url: 'https://polygon-rpc.com/'
  }
}

What can I do to run it forever or reconnect after disconnection?

I hope one of you does have an idea. Thank you!

3
  • From the log seems to be a problem with the RPC provider. It is returning a timeout.
    – Ismael
    Commented Aug 26, 2022 at 4:32
  • Do you know how to hold the connection or reconnect?
    – Dani S
    Commented Aug 26, 2022 at 14:33
  • It is a provider issue. Check with their support. Usually the free ones have strict limits on how many queries you can perform or you have to register with them.
    – Ismael
    Commented Aug 26, 2022 at 16:50

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.