harmonyland / discord_rpc

Discord RPC module for Deno.
https://deno.land/x/discord_rpc
MIT License
14 stars 4 forks source link

Imposible to connect to Discord #13

Open CarlosNunezMX opened 2 years ago

CarlosNunezMX commented 2 years ago

When I start the app with all required flags that shows this errors

error: Uncaught (in promise) RangeError: IPC ID must be between 0-9
  if (id < 0 || id > 9) throw new RangeError(`IPC ID must be between 0-9`);
                              ^
    at getIPCPath (https://deno.land/x/discord_rpc@0.3.0/src/util.ts:14:31)
    at findIPC (https://deno.land/x/discord_rpc@0.3.0/src/util.ts:30:16)
    at findIPC (https://deno.land/x/discord_rpc@0.3.0/src/util.ts:41:12)
    at async Function.connect (https://deno.land/x/discord_rpc@0.3.0/src/conn.ts:40:18)
    at async Client.connect (https://deno.land/x/discord_rpc@0.3.0/src/client.ts:85:16)
    at async file:///home/kuromi/Angel%20Beats!%20-1st%20beat-/rpc/index.ts:18:1

I give this flags

deno run --allow-run --allow-env --unstable --allow-read --allow-write --allow-net index.ts

And this is the connection part

const cliente = new Client({
    id: "980253379139891292",
    scopes: ["rpc"]
})

await cliente.connect();
Helloyunho commented 2 years ago

Hmm.. That's weird Can you check what path comes out from running the code below?

(Deno.env.get("XDG_RUNTIME_DIR") ?? Deno.env.get("TMPDIR") ?? Deno.env.get("TMP") ?? Deno.env.get("TEMP") ?? "/tmp")

And also check if there's something called discord-ipc-(number) in that directory

Preta-Crowz commented 1 year ago

Hmm.. That's weird Can you check what path comes out from running the code below?

(Deno.env.get("XDG_RUNTIME_DIR") ?? Deno.env.get("TMPDIR") ?? Deno.env.get("TMP") ?? Deno.env.get("TEMP") ?? "/tmp")

And also check if there's something called discord-ipc-(number) in that directory

Got same error, and there's no file/directory named like that under temp folder (tried to restart discord few times, but they don't generate it)

Helloyunho commented 1 year ago

Hmm.. That's weird Can you check what path comes out from running the code below?

(Deno.env.get("XDG_RUNTIME_DIR") ?? Deno.env.get("TMPDIR") ?? Deno.env.get("TMP") ?? Deno.env.get("TEMP") ?? "/tmp")

And also check if there's something called discord-ipc-(number) in that directory

Got same error, and there's no file/directory named like that under temp folder (tried to restart discord few times, but they don't generate it)

@Preta-Crowz can you try with this? https://raw.githubusercontent.com/harmonyland/discord_rpc/not-found-patch/mod.ts

Preta-Crowz commented 1 year ago

@Preta-Crowz can you try with this? https://raw.githubusercontent.com/harmonyland/discord_rpc/not-found-patch/mod.ts

Got same error

DjDeveloperr commented 1 year ago

Which OS are you on? And what directory does that expression return? Can you check what each part of it returns? Maybe there is priority issue in looking up tmpdir path.

Preta-Crowz commented 1 year ago

Which OS are you on? And what directory does that expression return? Can you check what each part of it returns? Maybe there is priority issue in looking up tmpdir path.

Windows 11 21H2, C:\\Users\\preta\\AppData\\Local\\Temp

DjDeveloperr commented 1 year ago

Right then the issue isn’t temp dir, Windows support is not working once again because FFI bindings are outdated. I’ll update them when I have time and release new version of deno namedpipe.

DjDeveloperr commented 1 year ago

Try again with v0.3.1, it should work.

viztea commented 1 year ago

I'm getting the same error on Windows 10 22H2 w/ 0.3.1

cli

deno run --unstable --allow-all mod.ts

temp dir

C:\\Users\\Gino\\AppData\\Local\\Temp

Preta-Crowz commented 1 year ago

Try again with v0.3.1, it should work.

sorry for late, it's still not working with another error


  return lpBufferView.getCString();
                      ^
    at UnsafePointerView.getCString (deno:ext/ffi/00_ffi.js:117:18)
    at FormatMessage (https://deno.land/x/win@0.2.0/error.ts:20:23)
    at new Win32Error (https://deno.land/x/win@0.2.0/error.ts:28:23)
    at unwrap (https://deno.land/x/win@0.2.0/error.ts:41:11)
    at NamedPipe.write (https://deno.land/x/namedpipe@0.1.1/client.ts:78:5)
    at DiscordIPC.send (https://deno.land/x/discord_rpc@0.3.1/src/conn.ts:81:27)
    at https://deno.land/x/discord_rpc@0.3.1/src/conn.ts:123:12
    at new Promise (<anonymous>)
    at DiscordIPC.login (https://deno.land/x/discord_rpc@0.3.1/src/conn.ts:121:12)
    at Client.connect (https://deno.land/x/discord_rpc@0.3.1/src/client.ts:87:20)```
Helloyunho commented 1 year ago

seems like namedpipe is still having some issues @DjDeveloperr

DjDeveloperr commented 1 year ago

I'll look into it... it somehow works fine on Windows for me

pagoru commented 3 months ago

Still not working...

DjDeveloperr commented 3 months ago

Can you provide the error you got? @pagoru

pagoru commented 3 months ago

@DjDeveloperr I'm using Deno, when I compile it to production, the problem doesn't occur, it only occurs when I launch it on development. It happens on linux, mac and windows. Maybe a permissions thing?

RangeError: IPC ID must be between 0-9 at getIPCPath (https://deno.land/x/discord_rpc@0.3.2/src/util.ts:14:31) at findIPC (https://deno.land/x/discord_rpc@0.3.2/src/util.ts:30:16) at findIPC (https://deno.land/x/discord_rpc@0.3.2/src/util.ts:41:12) at eventLoopTick (ext:core/01_core.js:168:7) at async Function.connect (https://deno.land/x/discord_rpc@0.3.2/src/conn.ts:40:18) at async Client.connect (https://deno.land/x/discord_rpc@0.3.2/src/client.ts:85:16) at async _setActivity (file:///home/pagoru/c/voidpixel/game/app/services/src/wss/events/discord/discord-rich-presence.event.ts:30:5)

DjDeveloperr commented 3 months ago

I think the cause is poor error handling. I'll update the library to show better errors as to why the IPC path could not be found.

pagoru commented 3 months ago

I think the cause is poor error handling. I'll update the library to show better errors as to why the IPC path could not be found.

That's really cool, if you need help, ping me! :dancers:

DjDeveloperr commented 3 months ago

@pagoru Can you try importing from latest commit i.e. https://raw.githubusercontent.com/harmonyland/discord_rpc/c68f9dde6ddad243f67d252d4409fe1117a98822/mod.ts ?

pagoru commented 3 months ago

@pagoru Can you try importing from latest commit i.e. https://raw.githubusercontent.com/harmonyland/discord_rpc/c68f9dde6ddad243f67d252d4409fe1117a98822/mod.ts ?

RangeError: Tried all possible IPC paths 0-9, make sure Discord is open. It must be installed locally, not just open on a web browser. at getIPCPath (https://raw.githubusercontent.com/harmonyland/discord_rpc/c68f9dde6ddad243f67d252d4409fe1117a98822/src/util.ts:15:11) at findIPC (https://raw.githubusercontent.com/harmonyland/discord_rpc/c68f9dde6ddad243f67d252d4409fe1117a98822/src/util.ts:34:16) at findIPC (https://raw.githubusercontent.com/harmonyland/discord_rpc/c68f9dde6ddad243f67d252d4409fe1117a98822/src/util.ts:39:18) at eventLoopTick (ext:core/01_core.js:168:7) at async findIPC (https://raw.githubusercontent.com/harmonyland/discord_rpc/c68f9dde6ddad243f67d252d4409fe1117a98822/src/util.ts:39:12) at async findIPC (https://raw.githubusercontent.com/harmonyland/discord_rpc/c68f9dde6ddad243f67d252d4409fe1117a98822/src/util.ts:39:12) at async findIPC (https://raw.githubusercontent.com/harmonyland/discord_rpc/c68f9dde6ddad243f67d252d4409fe1117a98822/src/util.ts:39:12) at async findIPC (https://raw.githubusercontent.com/harmonyland/discord_rpc/c68f9dde6ddad243f67d252d4409fe1117a98822/src/util.ts:39:12) at async findIPC (https://raw.githubusercontent.com/harmonyland/discord_rpc/c68f9dde6ddad243f67d252d4409fe1117a98822/src/util.ts:39:12) at async findIPC (https://raw.githubusercontent.com/harmonyland/discord_rpc/c68f9dde6ddad243f67d252d4409fe1117a98822/src/util.ts:39:12)

DjDeveloperr commented 3 months ago

That is weird. It means that the IPC path simply did not exist on your system... You're on Windows right? Edit: nvm, you seem to be on Linux from your previous error message.

DjDeveloperr commented 3 months ago

What do you get when you run this expression in Deno REPL?

(Deno.env.get("XDG_RUNTIME_DIR") ?? Deno.env.get("TMPDIR") ?? Deno.env.get("TMP") ?? Deno.env.get("TEMP") ?? "/tmp")

Does the directory exist? And is there a socket called discord-ipc-{0,9} in it?

pagoru commented 3 months ago
(Deno.env.get("XDG_RUNTIME_DIR") ?? Deno.env.get("TMPDIR") ?? Deno.env.get("TMP") ?? Deno.env.get("TEMP") ?? "/tmp")

/run/user/1000

DjDeveloperr commented 3 months ago

When I check the contents of the path returned by that expression on macOS,

ls -l $(deno eval -p '(Deno.env.get("XDG_RUNTIME_DIR") ?? Deno.env.get("TMPDIR") ?? Deno.env.get("TMP") ?? Deno.env.get("TEMP") ?? "/tmp")') | grep discord

I get this:

image

Can you check the contents?