CONNECTION ERROR: Couldn't connect to node https://public-node-api.klaytnapi.com/v1/cypress

잘 될 때가 있고 안될 때가 있습니다. KAS Public Node를 사용하여 사용량 제한에 따라 발생한 에러일까요? 그렇다면 에러 메시지가 왜 연결할 수 없다고 뜨나요?

const KLAYTN_RPC_URL = 'https://public-node-api.klaytnapi.com/v1/cypress';
export const caver = new Caver(KLAYTN_RPC_URL);
  • klaytnContractAddr: 0x089403168721ef1728ee97e6797c55b5abfc1d7a
  • klaytnWalletAddr:개인 지갑 주소

관련 코드는:

import { error } from ‘@sveltejs/kit’;
import type { RequestHandler } from ‘@sveltejs/kit’;

import type { WalletData } from ‘$root/types/api’;
import { caver } from ‘$root/lib/caver’;

export const POST: RequestHandler = async ({ request }) => {
const { klaytnContractAddr, klaytnWalletAddr } = await request.json();

try {
const kip17 = await caver.kct.kip17.create(klaytnContractAddr);

  const name = await kip17.name();
  const symbol = await kip17.symbol();
  const balance = Number(await kip17.balanceOf(klaytnWalletAddr));
  const totalSupply = Number(await kip17.totalSupply());

  const walletData: WalletData = { name, symbol, balance, totalSupply };

  return new Response(JSON.stringify(walletData), {
  	status: 200
  });

} catch (err) {
console.error(err);
throw error(400, Have trouble with Klaytn call: ${err});
}
};

환경:

  • SvelteKit
  • WSL2, Windows 11

에러 메시지는:

Error: CONNECTION ERROR: Couldn’t connect to node https://public-node-api.klaytnapi.com/v1/cypress.
at Object.InvalidConnection (/home/s/dev/discord-bot-frontend/node_modules/caver-js/packages/caver-core-helpers/src/errors.js:63:32)
at HttpProvider.failed (/home/s/dev/discord-bot-frontend/node_modules/caver-js/packages/caver-core-requestmanager/caver-providers-http/src/index.js:169:25)
at runMicrotasks ()
at processTicksAndRejections (node:internal/process/task_queues:96:5)