Windows – How to reproduce read ETIMEDOUT with node_redis on the local dev machine

debiannode.jswindows

I'm periodically getting Redis connection to xxxx:xxxx failed - connect ETIMEDOUT errors on my node.js app servers which are using node_redis to connect to a redis server. (The servers are in a cloud environment, and the errors happen around midnight – I'm assuming some kind of network disruption).

The application doesn't seem to be handling this situation very well, and I'm trying to recreate the scenario locally to try and improve things.

However, I'm unable to cause an ETIMEDOUT with the steps I've taken to simulate the problem. I suspect this may be to do with the fact that both the app and redis are residing on the same dev machine, or perhaps it's because the dev environment is windows and the production env is linux.

Could anyone suggest how I might recreate the ETIMEDOUT error locally?

Best Answer

if it's the app you are trying to debug or make it handle the error proper, make it connect on a fake redis server (e.g. on your linux machine IP.AD.RE.SS:61610) and drop the packets to that port with iptables. drop, don't reject (iptables -A INPUT -p tcp --dport 61610 -j DROP. that should give you an ETIMEDOUT locally when trying to connect to fake server. if you just want RANDOM timeouts you can doit from iptables as well (forward only some connections to real redis service and drop the rest)

Related Topic