Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Unhandled Error ECONNRESET #196

Copy link
Copy link
@Schlabbi

Description

@Schlabbi
Issue body actions

Describe the bug
Unhandled error due to ECONNRESET crashes my script. Already tried to catch the error with .on("error"), but the error is still unhandled and will crash my node script. The error and my connection setup are down below.

To Reproduce
No direct way to reproduce, this occurs a few minutes after I established the connection (even with commands being sent).

Expected behavior
No unhandled exceptions.

Versions used

  • TeamSpeak Server Version: 3.13.7
  • NodeJS Version (check with node -v): v20.12.0
  • Library Version: 3.5.1

Additional context

node:events:496
throw er; // Unhandled 'error' event
^

Error: read ECONNRESET
at TCP.onStreamRead (node:internal/stream_base_commons:217:20)
at TCP.callbackTrampoline (node:internal/async_hooks:130:17)
Emitted 'error' event on ProtocolRAW instance at:
at ProtocolRAW.handleError (C:\Users<redacted><myProject>\node_modules\ts3-nodejs-library\lib\transport\protocols\raw.js:41:14)
at Socket.emit (node:events:518:28)
at emitErrorNT (node:internal/streams/destroy:169:8)
at emitErrorCloseNT (node:internal/streams/destroy:128:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
errno: -4077,
code: 'ECONNRESET',
syscall: 'read'
}

Node.js v20.12.0

And here is my connection setup:

import { 
    QueryProtocol,
    TeamSpeak 
} from "ts3-nodejs-library";
import logService from "./logger";
import config from "../config";

const logger = logService(module);

const connectionOptions: Partial<TeamSpeak.ConnectionParams> =  {
    host: config.ts3.host,
    protocol: QueryProtocol.RAW,
    queryport: config.ts3.queryPort,
    serverport: config.ts3.serverport,
    username: config.ts3.username,
    password: config.ts3.password,
    nickname: "Nickname",
    keepAlive: true
};

const connectionBuilder: Promise<TeamSpeak> = (async () => {
    try {
        logger.info("Trying to establish TS3 Connection");
        const ts3 = new TeamSpeak(connectionOptions);
        await ts3.connect();
        logger.info("Successfully connected to TS3");

        ts3.on("close", async () => {
            try {
                logger.warning("disconnected, trying to reconnect...");
                await ts3.reconnect(-1, 1000);
                logger.warning("reconnected!");
            } catch (error) {
                logger.error(`Error while reconnecting to TS3: ${JSON.stringify(error)}`);
                process.exit(1);
            }
        });

        ts3.on("error", async () => {
            try {
                logger.warning("disconnected, trying to reconnect...");
                await ts3.reconnect(-1, 1000);
                logger.warning("reconnected!");
            } catch (error) {
                logger.error(`Error while reconnecting to TS3: ${JSON.stringify(error)}`);
                process.exit(1);
            }
        });

        return ts3;
    } catch(error) {
        logger.error(`Error while establishing TS3 connection: ${JSON.stringify(error)}`);
        process.exit(1);
    }
})();

export default connectionBuilder;
TheCode-dev

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.