Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECONNRESET on long idle time #678

Open
jumpingaccess opened this issue Oct 27, 2023 · 7 comments
Open

ECONNRESET on long idle time #678

jumpingaccess opened this issue Oct 27, 2023 · 7 comments

Comments

@jumpingaccess
Copy link

HI,everyone,
I got this on nodecg when no use of the dashboard is done for long time ( example between evening and next morning).

UNCAUGHT EXCEPTION! NodeCG will now exit.
Error: read ECONNRESET
at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
at __node_internal_errnoException (node:internal/errors:623:12)
at TCP.onStreamRead (node:internal/stream_base_commons:217:20) {
errno: -104,
code: 'ECONNRESET',
syscall: 'read',
fatal: true
}
UNCAUGHT EXCEPTION! NodeCG will now exit.
Error: Connection lost: The server closed the connection.
at Socket. (/home/laurent/nodecg/node_modules/mysql2/lib/connection.js:117:31)
at Socket.emit (node:events:514:28)
at Socket.emit (node:domain:489:12)
at TCP. (node:net:323:12) {
fatal: true,
code: 'PROTOCOL_CONNECTION_LOST'
}

Is it a way to have a keepalive or something like this ? the bundle I've made use a websocket connection and i have to re setup everything when I've to restart it

thanks in advance

@from-the-river-to-the-sea
Copy link
Contributor

My guess is that somewhere in your bundle's extension is a long-living object (such as a MySQL connection using that mysql2 library I see in the stack trace) and that this object needs to have an error event handler added to it so that any errors it throws don't cause an uncaught exception. This is a somewhat common pattern in Node.js -- if there's an error handler, it gets the errors. Else, errors are uncaught and crash the program.

@from-the-river-to-the-sea
Copy link
Contributor

To clarify, I mean you might need only do this:

yourSocketOrWhatever.on('error', (error) => {
    nodecg.log.error(error)
})

@jumpingaccess
Copy link
Author

this is not the websocket client that close , but nodecg itself , websocket server is created on another software

@jumpingaccess
Copy link
Author

Websocket stream get information every 100 ms with a timetick

@jumpingaccess
Copy link
Author

mysql2 is an error I need to clean , not used anymore

@jumpingaccess
Copy link
Author

More on this , even my bundle is empty:

UNCAUGHT EXCEPTION! NodeCG will now exit.
Error: read ECONNRESET
at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
at __node_internal_errnoException (node:internal/errors:623:12)
at TCP.onStreamRead (node:internal/stream_base_commons:217:20) {
errno: -104,
code: 'ECONNRESET',
syscall: 'read',
fatal: true
}

@jumpingaccess
Copy link
Author

HI ,
Solution found :
var KeepAliveAgent = require('keep-alive-agent'),
agent = new KeepAliveAgent();
in extension/index.js
and no more crashes after longperiod of inactivities

:)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants