Hey I’m trying to initialize concordium client and getting this error:
[Nest] 19092 - 01/07/2025, 5:27:27 PM ERROR [TraceService] Failed to initialize Concordium client
[Nest] 19092 - 01/07/2025, 5:27:27 PM ERROR [TraceService] RpcError: No connection established. Last error: connect ETIMEDOUT 34.36.245.204:20001 (2025-01-07T16:27:27.506Z)
Code: UNAVAILABLE
Method: concordium.v2.Queries/GetInstanceInfo
C:\Users\emi_m\OneDrive\Desktop\posao\mithras\mithras-be\node_modules\@protobuf-ts\grpc-transport\build\commonjs\grpc-transport.js:37
const e = new runtime_rpc_1.RpcError(err.details, grpc_js_1.status[err.code], util_1.metadataFromGrpc(err.metadata));
^
RpcError: No connection established. Last error: connect ETIMEDOUT 34.36.245.204:20001 (2025-01-07T16:27:27.506Z)
this is my function
constructor() {
this.loadSchema();
}
async onModuleInit() {
await this.initializeDependencies();
await this.initializeClient();
}
private async initializeDependencies() {
try {
// Dynamically import SDK
const webSdk = await import('@concordium/web-sdk');
const nodeClient = await import('@concordium/web-sdk/nodejs');
this.SDK = webSdk;
this.nodeClient = nodeClient;
this.logger.log('SDK dependencies loaded successfully');
} catch (error) {
this.logger.error('Failed to load SDK dependencies', error);
throw error;
}
}
private loadSchema() {
try {
const schemaPath = join(
__dirname,
'../../src/concordium/module-schema.bs64',
);
const rawSchema = readFileSync(schemaPath);
this.schema = Buffer.from(rawSchema);
} catch (error) {
this.logger.error('Failed to load schema', error);
throw error;
}
}
private async initializeClient() {
try {
const nodeAddress = process.env.CONCORDIUM_NODE_ADDRESS;
const nodePort = parseInt(process.env.CONCORDIUM_NODE_PORT || '20001');
const contractIndex = process.env.CONCORDIUM_CONTRACT_INDEX;
if (!nodeAddress || !contractIndex) {
throw new Error('Missing required environment variables');
}
const { ConcordiumGRPCNodeClient } = this.nodeClient;
this.client = new ConcordiumGRPCNodeClient(
nodeAddress,
nodePort,
credentials.createSsl(),
{
timeout: 30000,
'grpc.keepalive_time_ms': 120000,
'grpc.keepalive_timeout_ms': 20000,
},
);
// Create contract address using the new index
const contractAddress = {
index: BigInt(10532),
subindex: BigInt(0),
};
// Test if we can access the contract
const info = await this.client.getInstanceInfo(contractAddress);
this.logger.log('Contract successfully connected:', info);
this.logger.log('Concordium client initialized successfully');
} catch (error) {
this.logger.error('Failed to initialize Concordium client', error);
throw error;
}
}
my environment virables:
CONCORDIUM_NODE_ADDRESS=grpc.testnet.concordium.com
CONCORDIUM_CONTRACT_ADDRESS=contract_address
CONCORDIUM_NODE_PORT=20001
CONCORDIUM_CONTRACT_INDEX=contract_index
CONCORDIUM_CONTRACT_SUBINDEX=0
CONCORDIUM_ADMIN_ADDRESS=admin_address
does anyone see what is why it doesn’t want to connect to testnet, sorry I’m a newby in concordium blockchain