Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AxiosError: Request failed with status code 400 #53

Open
johnny-yue opened this issue Nov 18, 2024 · 6 comments
Open

AxiosError: Request failed with status code 400 #53

johnny-yue opened this issue Nov 18, 2024 · 6 comments

Comments

@johnny-yue
Copy link

I am running basically the same code as the examples, but some of the request will successfully return data but some will fail. This is the code I have:

async function getPoolInfo() {
  console.log(connection.rpcEndpoint);
  const raydium = await initSdk({ admin: adminKeyPair.publicKey, connection: connection });

  // This call will successfully return data
  const poolInfo = await raydium.liquidity.getRpcPoolInfos([RaySol]);
  console.log(poolInfo);

  // this will throw an error
  const data = await raydium.api.fetchPoolByMints({
    mint1: "So11111111111111111111111111111111111111112",
    mint2: "2qEHjDLDLbuBgRYvsxhc5D6uDWAivNFZGan56P1tpump",
  });

  console.log(data);
}

I am using the same initSdk as in the exsample.

Error message:

1731920546418 Raydium_Api sdk logger error GET https://api-v3.raydium.io/pools/info/mint?mint1=2qEHjDLDLbuBgRYvsxhc5D6uDWAivNFZGan56P1tpump&mint2=So11111111111111111111111111111111111111112&poolType=all&poolSortField=default&sortType=desc&pageSize=100&page=1 400

/Users/john/code/solana/solana-samples/node_modules/axios/lib/core/settle.js:19
    reject(new AxiosError(
           ^
AxiosError: Request failed with status code 400
    at settle (/Users/john/code/solana/solana-samples/node_modules/axios/lib/core/settle.js:19:12)

The linke (https://api-v3.raydium.io/pools/info/mint?mint1=2qEHjDLDLbuBgRYvsxhc5D6uDWAivNFZGan56P1tpump&mint2=So11111111111111111111111111111111111111112&poolType=all&poolSortField=default&sortType=desc&pageSize=100&page=1) can be opened on my local machine browser.

Running macos 14.2.1
Node.js: v22.8.0

@cruzshia
Copy link
Collaborator

if you can open on your local machine browser means api status is okay, it might cause by exceed rate limits?

@johnny-yue
Copy link
Author

The thing is in this example code, I always do 2 api calls (getRpcPoolInfos and ), no matter who goes first fetchPoolByMints always fail.

I have nothing else running on the local machine, so the chances of exceed rate limit feels low.

@cruzshia
Copy link
Collaborator

tried multiple times and everything goes well, skd version: 0.1.81-alpha

const raydium = await Raydium.load({
    connection: new Connection(clusterApiUrl("mainnet-beta")),
    disableFeatureCheck: true,
    disableLoadToken: true,
  });

  const poolInfo = await raydium.liquidity.getRpcPoolInfos(["6UmmUiYoBjSrhakAobJw8BvkmJtDVxaeBtbt7rxWo1mg"]);
  console.log(poolInfo);

  const data = await raydium.api.fetchPoolByMints({
    mint1: "So11111111111111111111111111111111111111112",
    mint2: "2qEHjDLDLbuBgRYvsxhc5D6uDWAivNFZGan56P1tpump",
  });

@johnny-yue
Copy link
Author

I just ran your code on my local machine and got the same error.

`
1732073441957 Raydium_Api sdk logger error GET https://api-v3.raydium.io/pools/info/mint?mint1=2qEHjDLDLbuBgRYvsxhc5D6uDWAivNFZGan56P1tpump&mint2=So11111111111111111111111111111111111111112&poolType=all&poolSortField=default&sortType=desc&pageSize=100&page=1 400

/Users/john/code/solana/solana-samples/node_modules/axios/lib/core/settle.js:19
reject(new AxiosError(
`

Would you look at this AxiosError and share some knowledge about it? I haven't used this Axios lib before, i don't see it in the package.json.

Could it be a version mismatch?

@cruzshia
Copy link
Collaborator

I can't see any clue in this error code, maybe you can use familiar api call function to call this api, url definition is here.

@johnny-yue
Copy link
Author

More infomation about the error

code: 'ERR_BAD_REQUEST',
  config: {
   ...

      Accept: 'application/json, text/plain, */*',
      'Content-Type': undefined,
      'User-Agent': 'axios/1.7.2',
      'Accept-Encoding': 'gzip, compress, deflate, br'
    },
    baseURL: 'https://api-v3.raydium.io',
    method: 'get',
    url: '/pools/info/ids?ids=AVs9TA4nWDzfPJE9gGVNJMVhcQy3V9PGazuz33BfG2RA',
    data: undefined
  },
    data: '<html>\r\n' +
      '<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>\r\n' +
      '<body>\r\n' +
      '<center><h1>400 Bad Request</h1></center>\r\n' +
      '<center>The plain HTTP request was sent to HTTPS port</center>\r\n' +
      '<hr><center>cloudflare</center>\r\n' +
      '</body>\r\n' +
      '</html>\r\n'
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants