I am getting this error: Access denied | hermes-beta.pyth.network used Cloudflare to restrict access

I’m frequently encountering the following error when generating the payload using the update_price_feeds_with_funder function

</html>

    at HermesClient.httpRequest (/app/node_modules/@pythnetwork/hermes-client/lib/HermesClient.js:39:23)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Failed to update Pyth price payload:  Error: HTTP error! status: 429, body: <!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en-US"> <![endif]-->
<!--[if IE 7]>    <html class="no-js ie7 oldie" lang="en-US"> <![endif]-->
<!--[if IE 8]>    <html class="no-js ie8 oldie" lang="en-US"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en-US"> <!--<![endif]-->
<head>
<title>Access denied | hermes-beta.pyth.network used Cloudflare to restrict access</title>
<meta charset="UTF-8" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta name="robots" content="noindex, nofollow" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<link rel="stylesheet" id="cf_styles-css" href="/cdn-cgi/styles/main.css" />

at HermesClient.httpRequest (/app/node_modules/@pythnetwork/hermes-client/lib/HermesClient.js:39:23) at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

It seems like the Hermes client is being rate-limited or blocked by Cloudflare, returning a 429 status code and an HTML response instead of the expected data. The error appears to originate from this part of the stack:

Could someone please help investigate and resolve this issue ?

The public hermes instances have rate limits (similar to this) but it is very generous and you shouldn’t normally hit it. I’m wondering how often you are hitting the endpoint that is resulting in ratelimit. If you want to get the data frequently I recommend using the streaming endpoint.

Hi @ali

Here’s the code we’re currently using:

export const updatePythPricePayload = async (marketId: string) => {
    try {
        const priceIds = [MARKET_PRICE_FEEDS[marketId]];
        const connection = new HermesClient(process.env.PYTH_HERMES_ENDPOINT!, {});
        const priceFeedUpdateData = await connection.getLatestPriceUpdates(priceIds, {
            encoding: "base64",
        });
        const binaryDataAsNumbers: number[][] = priceFeedUpdateData.binary.data.map((base64String: string) =>
            Array.from(Buffer.from(base64String, "base64"))
        );
        const payloadResponse = {
            function: "0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387::pyth::update_price_feeds_with_funder",
            functionArguments: [binaryDataAsNumbers],
            typeArguments: [],
        } as InputEntryFunctionData;
        return payloadResponse;
    } catch (error: any) {
        console.log("Failed to update Pyth price payload: ", error);
        rollbar.error("Failed to update Pyth price payload.", error);
    }
};

We have configured the following environment variables:

  • PYTH_HERMES_ENDPOINT=https://hermes-beta.pyth.network
  • APT_PRICE_FEED_ID=0x44a93dddd8effa54ea51076c4e851b6cbbfd938e82eb90197de38fe8876bb66e

We’re using three price feed IDs: APT, BTC, and ETH. Every 20 seconds, we fetch the payloads for all three feeds and submit the corresponding transactions.

We use the following function to update the prices:

0x7e783b349d3e89cf5931af376ebeadbfab855b3fa239b7ada8f5a92fbea6b387::pyth::update_price_feeds_with_funder

We also have a function to update the funding rate. For this, we fetch data from https://hermes-beta.pyth.network for the same three price feed IDs and submit the transaction every 1 minute.

Let me know if you need any further details.

I double checked the ratelimit and it’s 29 requests every 10 seconds and if you make 1 every 20 seconds it shouldn’t hit it. Can you double check your code? The part that you shared doesn’t seem to have any problem.

Thanks @ali Let me check it thoroughly. I’ve added logs line by line, and I’ll share here if I find any differences.