Algorand Network Connection Bug

I am having trouble with network connection. I am working in a react app. I have tried two different methods for connecting to the Algorand Network. However, the problem is the network is consistently failing to respond.

My preferred method to connect is via AlgoExplorer, but I read they were stopping service. So, I wasn’t sure if that was causing the error. So, I switched to PureStake, which is also failing. I do not have enough information to debug further from the console logs. Any suggestions would be appreciated. Thanks.

Purestake Network Connection Mechanism

const algod_address = "https://mainnet-algorand.api.purestake.io/ps2"
const algod_token = ""
const headers = {"X-API-Key": algod_token }
const algodClient = new algosdk.Algodv2(algod_token, algod_address, headers);

Error

mainnet-algorand.api.purestake.io/ps2/v2/transactions/params:1 Failed to load resource: net::ERR_FAILED

AlgoExplorer Network Connection Mechanism

const algod_address = "https://node.algoexplorerapi.io"
const algod_token = ""
const headers = {"X-API-Key": algod_token }
const algodClient = new algosdk.Algodv2(algod_token, algod_address, headers);

Error

browser-ponyfill.js:518 GET https://node.algoexplorerapi.io/v2/transactions/params net::ERR_NAME_NOT_RESOLVED

AlgoExplorer newer had X-API-Key header there… they used the standard one X-Algo-API-Token REST Endpoints - Algorand Developer Portal but in mid june they were supposed to turn off public node access…

When reporting the error, it might be much better to show also the response code, some screenshot from network tab and what you try to fetch…

Have you tried the AlgoNode? At the moment it is the only free (permissionless) algorand node provider i know of…

For example

https://mainnet-api.algonode.cloud/v2/transactions/params

returns

{"consensus-version":"https://github.com/algorandfoundation/specs/tree/44fa607d6051730f5264526bf3c108d51f0eadb6","fee":0,"genesis-hash":"wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=","genesis-id":"mainnet-v1.0","last-round":30010043,"min-fee":1000}
1 Like

Thanks, boss. I changed it.

Network Connection Mechanism

const algod_address = "https://mainnet-api.algonode.cloud/v2/transactions/params"
const algod_token = ""
const headers = {"X-API-Key": algod_token }
const algodClient = new algosdk.Algodv2(algod_token, algod_address, headers);

Error

browser-ponyfill.js:518     GET https://mainnet-api.algonode.cloud/v2/transactions/params/v2/transactions/params 404
(anonymous) @ browser-ponyfill.js:518
fetch @ browser-ponyfill.js:455
get @ urlTokenBaseHTTPClient.ts:165
get @ client.ts:239
do @ jsonrequest.ts:61
transaction @ App.js:30
guess @ App.js:149
callCallback @ react-dom.development.js:4164
invokeGuardedCallbackDev @ react-dom.development.js:4213
invokeGuardedCallback @ react-dom.development.js:4277
invokeGuardedCallbackAndCatchFirstError @ react-dom.development.js:4291
executeDispatch @ react-dom.development.js:9041
processDispatchQueueItemsInOrder @ react-dom.development.js:9073
processDispatchQueue @ react-dom.development.js:9086
dispatchEventsForPlugins @ react-dom.development.js:9097
(anonymous) @ react-dom.development.js:9288
batchedUpdates$1 @ react-dom.development.js:26140
batchedUpdates @ react-dom.development.js:3991
dispatchEventForPluginEventSystem @ react-dom.development.js:9287
dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay @ react-dom.development.js:6465
dispatchEvent @ react-dom.development.js:6457
dispatchDiscreteEvent @ react-dom.development.js:6430
App.js:44 URLTokenBaseHTTPError: Network request error. Received status 404 (): Not Found
    at URLTokenBaseHTTPClient.checkHttpError (urlTokenBaseHTTPClient.ts:135:1)
    at async URLTokenBaseHTTPClient.formatFetchResponse (urlTokenBaseHTTPClient.ts:145:1)
    at async HTTPClient.get (client.ts:239:1)
    at async SuggestedParamsRequest.do (jsonrequest.ts:61:1)
    at async transaction (App.js:30:1)
    at async guess (App.js:149:1)

Moving Forward

How are you connecting to the Node? I am attempting to connect via a React App through the App.js file.

I do not have reference for what you mean:

https://mainnet-api.algonode.cloud/v2/transactions/params

Returns

{"consensus-version":"https://github.com/algorandfoundation/specs/tree/44fa607d6051730f5264526bf3c108d51f0eadb6","fee":0,"genesis-hash":"wGHE2Pwdvd7S12BL5FaOP20EGYesN73ktiC1qzkkit8=","genesis-id":"mainnet-v1.0","last-round":30010043,"min-fee":1000}

Are you able to explain the significance of your mechanism or how to use it in an application?

Thanks.

I also ran the following.

Network Connection Mechanism

// algoClient
const token = '';
const server = 'https://xna-mainnet-api.algonode.cloud ';
const port = 443;
const algodClient = new algosdk.Algodv2(token, server, port);

Error
browser-ponyfill.js:518 GET https://xna-mainnet-api.algonode.cloud%20/v2/transactions/params net::ERR_NAME_NOT_RESOLVED

(anonymous)	@	browser-ponyfill.js:518
fetch	@	browser-ponyfill.js:455
get	@	urlTokenBaseHTTPClient.ts:165
get	@	client.ts:239
do	@	jsonrequest.ts:61
transaction	@	App.js:31
guess	@	App.js:150
callCallback	@	react-dom.development.js:4164
invokeGuardedCallbackDev	@	react-dom.development.js:4213
invokeGuardedCallback	@	react-dom.development.js:4277
invokeGuardedCallbackAndCatchFirstError	@	react-dom.development.js:4291
executeDispatch	@	react-dom.development.js:9041
processDispatchQueueItemsInOrder	@	react-dom.development.js:9073
processDispatchQueue	@	react-dom.development.js:9086
dispatchEventsForPlugins	@	react-dom.development.js:9097
(anonymous)	@	react-dom.development.js:9288
batchedUpdates$1	@	react-dom.development.js:26140
batchedUpdates	@	react-dom.development.js:3991
dispatchEventForPluginEventSystem	@	react-dom.development.js:9287
dispatchEventWithEnableCapturePhaseSelectiveHydrationWithoutDiscreteEventReplay	@	react-dom.development.js:6465
dispatchEvent	@	react-dom.development.js:6457
dispatchDiscreteEvent

you have extra space in the domain name

note that algonode does not use x-api-key header… so change it to

const headers = {"X-Algo-API-Token": algod_token }
browser-ponyfill.js:518     GET https://mainnet-api.algonode.cloud/v2/transactions/params/v2/transactions/params 404

this should tell you you should not put to algod address

but

const algod_address = "https://mainnet-api.algonode.cloud"
1 Like

That worked. Thank you.