Hi,
I have a nodejs server running with a DB. They are communicating throught HTTP with undici client
Here is my undici global agent :
const dnsCache = new CacheableLookup();
const agent = new Agent({
// @ts-expect-error -- this is safe https://github.com/nodejs/undici/tree/main/docs/examples#using-cacheablelookup-to-cache-dns-lookups-in-undici
connect: {
lookup: dnsCache.lookup.bind(dnsCache),
keepAlive: true,
timeout: 10_000,
allowH2: true,
},
bodyTimeout: 60_000,
headersTimeout: 60_000,
allowH2: true,
keepAliveTimeout: 10_000,
});
Sometime, i run into this error :
"err":{"type":"SocketError","message":"other side closed","stack":"SocketError: other side closed\n at Socket.onHttpSocketEnd (/home/node/app/node_modules/.pnpm/undici@7.3.0/node_modules/undici/lib/dispatcher/client-h1.js:902:22)\n at Socket.emit (node:events:530:35)\n at endReadableNT (node:internal/streams/readable:1698:12)\n at process.processTicksAndRejections (node:internal/process/task_queues:90:21)","name":"SocketError","code":"UND_ERR_SOCKET","socket":{"localAddress":"127.0.0.1","localPort":37560,"remoteAddress":"127.0.0.1","remotePort":8080,"remoteFamily":"IPv4","bytesWritten":62192889,"bytesRead":3705674}
and subsequence call produce then this error 3 or 4 times :
"err":{"type":"Error","message":"read ECONNRESET","stack":"Error: read ECONNRESET\n at TCP.onStreamRead (node:internal/stream_base_commons:216:20)\n at TCP.callbackTrampoline (node:internal/async_hooks:130:17)","errno":-104,"code":"ECONNRESET","syscall":"read"}
and after again, always this error in loop :
"err":{"type":"Error","message":"connect ECONNREFUSED 127.0.0.1:8080","stack":"Error: connect ECONNREFUSED 127.0.0.1:8080\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1634:16)\n at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17)","errno":-111,"code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8080}
To fix it, i need to resart the pod containing the app and the DB.
Can somebody explain to me if my configuration is not OP ?
Is this an undici bug which not re-open a socket after the previous one was closed by the DB ?
This can be a DB error too, but it would be great if someone here can explain to me what happens, i'm not even sure what to think about those errors.
Not related question : is CacheableLookup does the same as the dns interceptor ? Should i use dns interceptor then ? If so, we probably update your documentation
Hi,
I have a nodejs server running with a DB. They are communicating throught HTTP with undici client
Here is my undici global agent :
Sometime, i run into this error :
"err":{"type":"SocketError","message":"other side closed","stack":"SocketError: other side closed\n at Socket.onHttpSocketEnd (/home/node/app/node_modules/.pnpm/undici@7.3.0/node_modules/undici/lib/dispatcher/client-h1.js:902:22)\n at Socket.emit (node:events:530:35)\n at endReadableNT (node:internal/streams/readable:1698:12)\n at process.processTicksAndRejections (node:internal/process/task_queues:90:21)","name":"SocketError","code":"UND_ERR_SOCKET","socket":{"localAddress":"127.0.0.1","localPort":37560,"remoteAddress":"127.0.0.1","remotePort":8080,"remoteFamily":"IPv4","bytesWritten":62192889,"bytesRead":3705674}and subsequence call produce then this error 3 or 4 times :
"err":{"type":"Error","message":"read ECONNRESET","stack":"Error: read ECONNRESET\n at TCP.onStreamRead (node:internal/stream_base_commons:216:20)\n at TCP.callbackTrampoline (node:internal/async_hooks:130:17)","errno":-104,"code":"ECONNRESET","syscall":"read"}and after again, always this error in loop :
"err":{"type":"Error","message":"connect ECONNREFUSED 127.0.0.1:8080","stack":"Error: connect ECONNREFUSED 127.0.0.1:8080\n at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1634:16)\n at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17)","errno":-111,"code":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":8080}To fix it, i need to resart the pod containing the app and the DB.
Can somebody explain to me if my configuration is not OP ?
Is this an undici bug which not re-open a socket after the previous one was closed by the DB ?
This can be a DB error too, but it would be great if someone here can explain to me what happens, i'm not even sure what to think about those errors.
Not related question : is CacheableLookup does the same as the dns interceptor ? Should i use dns interceptor then ? If so, we probably update your documentation