Reputation: 21
Soo basically i made a Discord rich presence extension for when im on a specific site and I noticed i cant use node.js for it but if I use browserify I can work around that with a bundled script. The problem is that i get WebSocketTransport errors and i don't know how to solve those. I have little experience with programming and i mostly create discord bots. I am using discord-rpc node module because i have experience with it and Im only getting errors when i use the discord-rpc module.
Error:
bundle.js:3177 Uncaught (in promise) Error: connection closed
at WebSocketTransport.<anonymous> (bundle.js:3177:16)
at Object.onceWrapper (bundle.js:2179:26)
at WebSocketTransport.emit (bundle.js:2089:5)
at WebSocketTransport.onClose (bundle.js:4147:10)
bundle.js:3166 Uncaught (in promise) Error: RPC_CONNECTION_TIMEOUT
at bundle.js:3166:47
The way i defined the module:
const clientId = '865555817466298408';
const RPC = require('discord-rpc');
const scopes = ['rpc', 'rpc.api', 'messages.read'];
const client = new RPC.Client({ transport: 'websocket' });
The Location of the error:
async connect() {
const port = 6463 + (this.tries % 10);
this.tries += 1;
this.ws = new WebSocket(
`ws://127.0.0.1:${port}/?v=1&client_id=${this.client.clientId}`,
browser ? undefined : { origin: this.client.options.origin },
);
this.ws.onopen = this.onOpen.bind(this);
this.ws.onclose = this.onClose.bind(this);
this.ws.onerror = this.onError.bind(this);
this.ws.onmessage = this.onMessage.bind(this);
}
Upvotes: 1
Views: 1118