Getting Timeout errors when load increases in ioredis - node.js

We're using a NodeJS-based app using express for routing http requests. Before routing the requests we have a middleware to perform some validation using Redis, wherein we use ioredis.
When the load is moderate it works fine. But when there is an increase in load, ioredis started throwing timeout errors.
Error: Command timed out at Timeout._onTimeout (/proj/node_modules/ioredis/built/command.js:261:33) at listOnTimeout (internal/timers.js:554:17) at processTimers (internal/timers.js:497:7)
[stack]: 'Error: Command timed out\n' + ' at Timeout._onTimeout (/proj/node_modules/ioredis/built/command.js:261:33)\n' at listOnTimeout (internal/timers.js:554:17)\n' + ' at processTimers (internal/timers.js:497:7)',
[message]: 'Command timed out'
Initially, we had the command timeout set as 2 seconds. It started throwing the error frequently. Post that we now changed it to 5 seconds. It was better than before, but still, we face the timeout issue when the load increases.
We didn't find any redis slowlog too. We're using a Kubernetes setup within which we use redis sentinels ( 1 master 2 slaves ) to connect to from the app.
Any help on this query would be helpful

Related

Getting timeout on trying to create new react project

I am trying to create a new react project, I tried using both npm and yarn but I am getting a server timeout error in both cases. I also tried reinstalling node but that didn't help. I also tried resetting registry but even that didn't help. This is my error:
Trace:
Error: https://registry.npmjs.org/create-react-app: ETIMEDOUT
at Timeout._onTimeout (/usr/share/yarn/lib/cli.js:141550:19)
at listOnTimeout (node:internal/timers:559:17)
at processTimers (node:internal/timers:502:7)
How should I solve this?

How to fix NodeJS Firebase AdminSDK GoogleError?

NodeJS Firebase AdminSDK GoogleError: Total timeout of API google.firestore.v1.Firestore exceeded 600000 milliseconds before any response was received
I am running a Node script to commit batches to the firestore. After 5-10 minutes of running the script locally, this error is returned:
GoogleError: Total timeout of API google.firestore.v1.Firestore exceeded 600000 milliseconds before any response was received.
at repeat (E:\Personal\NodeJs\Scraper\node_modules\google-gax\build\src\normalCalls\retries.js:66:31)
at Timeout._onTimeout (E:\Personal\NodeJs\Scraper\node_modules\google-gax\build\src\normalCalls\retries.js:101:25)
at listOnTimeout (internal/timers.js:557:17)
at processTimers (internal/timers.js:500:7)
Caused by: Error
at WriteBatch.commit (E:\Personal\NodeJs\Scraper\node_modules\#google-cloud\firestore\build\src\write-batch.js:417:23)
at upload (E:\Personal\NodeJs\Scraper\lib\index.js:127:23) {
code: 4
}
It is returned randomly whilst running the script so it is not an issue from the code.

Websocket NodeJS Crashing

Hey there im getting this error which is crashing my program after 12h or 24h and i have to restart it is there anyway to fix this?
ERROR :
/root/Chat/node_modules/ws/lib/websocket.js:334
throw new Error('WebSocket is not open: readyState 0 (CONNECTING)');
^
Error: WebSocket is not open: readyState 0 (CONNECTING)
at WebSocket.send (/root/Chat/node_modules/ws/lib/websocket.js:334:13)
at Timeout._onTimeout (/root/Chat/index.js:51:14)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
Code : https://hastebin.com/fayasobeha.js
Websockets are not a common TCP servers, They are more of 2 way connection between the Client and the Server. If you following any architecture(Micro/Mono) Make sure you check is there any other system thread going on at peak hours which is causing the crash.
It's always better if you can wrap your service in Container and run it as a separate process there.

Cannot detect timeout error from server api or client code ? Test with nodejs vs postman

I faced a problem that I cannot detect where it was, from server api or from my client code ?
API is product of my partner, so I cannot debug it, too.
If you've ever encountered an error like this, I'm grateful for your sharing.
Many thanks.
Here is my Postman request, evey requests was ok, got return as expected
Here is my simple code to make http post, got timeout error
got timeout error
{ Error: ETIMEDOUT
at Timeout.<anonymous> (F:\DEV\PROJECTS_IONIC\api\node_modules\request\request.js:848:19)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10) code: 'ETIMEDOUT', connect: true }

redis getaddrinfo ENOTFOUND - node.js , redis connection

Hi im trying to connect to redis from node.js which is successful, now i hosted my node.js server app on amazon ec2 instance and redis on amazon elastic cache instance the connection to redis is succesful but once in a while i'm getting the below mentioned error.
var pub = redis.createClient(6379,'quizredis.qnsdtp.0001.apse1.cache.amazonaws.com');
events.js:72
throw er; // Unhandled 'error' event
^ Error: Redis connection to quizredis.qnsdtp.0001.apse1.cache.amazonaws.com:6379 failed - getaddrinfo ENOTFOUND
at RedisClient.on_error (/home/ec2-user/roomChat-7/node_modules/redis/index.js:196:24)
at Socket.<anonymous> (/home/ec2-user/roomChat-7/node_modules/redis/index.js:106:14)
at Socket.EventEmitter.emit (events.js:95:17)
at net.js:813:16
Im using the redis-npm module;
From what I understand, this is a DNS resolution error.
Elasticache Redis is a VPC specific service. Its DNS records are available within the VPC only and often times, VPC is using custom DHCP options with custom DNS server - it may not have the records.
Check a few things -
DNS server configured in your VPC. Check here.
Check the output of nslookup command in your machine - if your using linux shell
nslookup quizredis.qnsdtp.0001.apse1.cache.amazonaws.com
Cheers!

Resources