discordjs / RPC

A simple RPC client for Discord

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error: connection closed

aidanngill opened this issue · comments

Testing out basic RPC and getting the error "connection closed". Tried switching transport to "websocket" but the same result happens. With and without scopes set it happens.

Running normal, stable Discord first by itself without administrator privileges.

Same issue happens even when running the basic example in the /example/ directory.

const DiscordRPC = require("discord-rpc");

const discordAppId = "app_id_here";
const discordAppScopes = ["rpc"];

DiscordRPC.register(discordAppId);
const rpcClient = new DiscordRPC.Client({ transport: "ipc" });

rpcClient.on("ready", () => {
  console.log(`Logged in as ${client.application.name}`);
});

rpcClient.login(discordAppId).catch(console.error);
C:\Projects\Javascript\Presence>node disc.js
Error: connection closed
    at WebSocketTransport.<anonymous> (C:\Projects\Javascript\Presence\node_modules\discord-rpc\src\client.js:111:16)
    at Object.onceWrapper (events.js:422:26)
    at WebSocketTransport.emit (events.js:315:20)
    at WebSocketTransport.onClose (C:\Projects\Javascript\Presence\node_modules\discord-rpc\src\transports\websocket.js:42:10)
    at WebSocket.onClose (C:\Projects\Javascript\Presence\node_modules\ws\lib\event-target.js:136:16)
    at WebSocket.emit (events.js:315:20)
    at WebSocket.emitClose (C:\Projects\Javascript\Presence\node_modules\ws\lib\websocket.js:198:10)
    at Socket.socketOnClose (C:\Projects\Javascript\Presence\node_modules\ws\lib\websocket.js:894:15)
    at Socket.emit (events.js:315:20)
    at TCP.<anonymous> (net.js:674:12)

Things to consider when getting a connection closed/could not connect error:
• What transport are you using? If it's 'websocket', change that to 'ipc'
• Is the ID you are trying to login with your user ID? If so, get one from the developer portal instead
• Are you using the Discord app? It won't be able to connect to the web version
• Is your code running on the same machine as the Discord app?
• Are you trying to run it from WSL? If so, it won't be able to connect either
• Have you installed Discord from the snap store? If so, install it from your distro's package repository or directly from the Discord website

commented

it is login({ clientId: xyz }), not login(xyz).