Lachee / discord-rpc-csharp

C# custom implementation for Discord Rich Presence. Not deprecated and still available!
MIT License
579 stars 96 forks source link

Fails to connect to pipe on macOS #59

Open Injazz opened 5 years ago

Injazz commented 5 years ago

while it works perfect on windows and linux, i fail to connect on macos. It spams the following:

ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc--1. Error on creating named pipe: error code -1
WARN: Tried to close a already closed pipe.
ERR : Failed to connect for some reason.
Lachee commented 5 years ago

snap.discord aaagh, another sandbox enviroment. Okay, can you please open your Discord console and tell me what is says for the following: [RPCServer:IPC] Starting on ________

You can open your Discord console by pressing ctrl + shift + i

Injazz commented 5 years ago
[RPCServer:IPC] Starting on /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T/discord-ipc-0
ghost commented 5 years ago

So i guess it connects to the wrong place?

Shouldnt the path here

[RPCServer:IPC] Starting on /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T/discord-ipc-0

be instead of the path it tries to connect to but fails.

while it works perfect on windows and linux, i fail to connect on macos. It spams the following:

ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc--1. Error on creating named pipe: error code -1
WARN: Tried to close a already closed pipe.
ERR : Failed to connect for some reason.
ghost commented 5 years ago

So I guess one thing you could try to do is change the path that it connects too

Injazz commented 5 years ago

https://github.com/Lachee/discord-rpc-csharp/blob/eddcae31a766e95ab3dcda186e13e0da3254bae5/DiscordRPC/IO/ManagedNamedPipeClient.cs#L438-L441 well, macos is unix, right? (mono thinks so sometimes) https://github.com/Lachee/discord-rpc-csharp/blob/eddcae31a766e95ab3dcda186e13e0da3254bae5/DiscordRPC/IO/ManagedNamedPipeClient.cs#L450-L451 https://www.mono-project.com/docs/faq/technical/#how-to-detect-the-execution-platform

Injazz commented 5 years ago

better use this System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.Linux); System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(OSPlatform.OSX);

Lachee commented 5 years ago

Can you give the entire log leading up to it failing? The snap.discord is normal and is it just trying sandbox enviroments additionally.

Injazz commented 5 years ago
INFO: Attempting a new connection
Thread started: Discord IPC Thread #2
INFO: Attempting to connect to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//discord-ipc-0
Loaded assembly: /Library/Frameworks/Mono.framework/Versions/5.16.1/lib/mono/gac/Mono.Posix/4.0.0.0__0738eb9f132ed756/Mono.Posix.dll [External]
ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//discord-ipc-0. Asynchronous pipe mode is not supported
WARN: Tried to close a already closed pipe.
INFO: Attempting to connect to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc-0
[DEBG] root: Switching to state SS14.Client.State.States.MainScreen
ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc-0. Error on creating named pipe: error code -1
WARN: Tried to close a already closed pipe.
INFO: Attempting to connect to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//discord-ipc-1
ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//discord-ipc-1. Asynchronous pipe mode is not supported
WARN: Tried to close a already closed pipe.
INFO: Attempting to connect to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc-1
ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc-1. Error on creating named pipe: error code -1
WARN: Tried to close a already closed pipe.
INFO: Attempting to connect to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//discord-ipc-2
ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//discord-ipc-2. Asynchronous pipe mode is not supported
WARN: Tried to close a already closed pipe.
INFO: Attempting to connect to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc-2
ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc-2. Error on creating named pipe: error code -1
WARN: Tried to close a already closed pipe.
INFO: Attempting to connect to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//discord-ipc-3
ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//discord-ipc-3. Asynchronous pipe mode is not supported
WARN: Tried to close a already closed pipe.
INFO: Attempting to connect to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc-3
ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc-3. Error on creating named pipe: error code -1
WARN: Tried to close a already closed pipe.
INFO: Attempting to connect to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//discord-ipc-4
ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//discord-ipc-4. Asynchronous pipe mode is not supported
WARN: Tried to close a already closed pipe.
INFO: Attempting to connect to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc-4
ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc-4. Error on creating named pipe: error code -1
WARN: Tried to close a already closed pipe.
INFO: Attempting to connect to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//discord-ipc-5
ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//discord-ipc-5. Asynchronous pipe mode is not supported
WARN: Tried to close a already closed pipe.
INFO: Attempting to connect to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc-5
ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc-5. Error on creating named pipe: error code -1
WARN: Tried to close a already closed pipe.
INFO: Attempting to connect to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//discord-ipc-6
ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//discord-ipc-6. Asynchronous pipe mode is not supported
WARN: Tried to close a already closed pipe.
INFO: Attempting to connect to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc-6
ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc-6. Error on creating named pipe: error code -1
WARN: Tried to close a already closed pipe.
INFO: Attempting to connect to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//discord-ipc-7
ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//discord-ipc-7. Asynchronous pipe mode is not supported
WARN: Tried to close a already closed pipe.
INFO: Attempting to connect to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc-7
ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc-7. Error on creating named pipe: error code -1
WARN: Tried to close a already closed pipe.
INFO: Attempting to connect to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//discord-ipc-8
ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//discord-ipc-8. Asynchronous pipe mode is not supported
WARN: Tried to close a already closed pipe.
INFO: Attempting to connect to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc-8
ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc-8. Error on creating named pipe: error code -1
WARN: Tried to close a already closed pipe.
INFO: Attempting to connect to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//discord-ipc-9
ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//discord-ipc-9. Asynchronous pipe mode is not supported
WARN: Tried to close a already closed pipe.
INFO: Attempting to connect to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc-9
ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc-9. Error on creating named pipe: error code -1
WARN: Tried to close a already closed pipe.
INFO: Attempting to connect to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//discord-ipc--1
ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//discord-ipc--1. Asynchronous pipe mode is not supported
WARN: Tried to close a already closed pipe.
INFO: Attempting to connect to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc--1
ERR : Failed connection to /var/folders/xc/wbs6jsyx4dq8_nd06b2zjg600000gr/T//snap.discord/discord-ipc--1. Error on creating named pipe: error code -1
WARN: Tried to close a already closed pipe.
ERR : Failed to connect for some reason.
Lachee commented 5 years ago

Alrighty, hopefully a fix to the issue. Can you please give that a try?

Injazz commented 5 years ago

still fails to connect, but the path is correct now, i guess it's the same issue as #54, although I got it worked on linux without unitynamedpipe

Injazz commented 5 years ago

Linux (Arch):

[INFO] discord: Attempting a new connection
[INFO] discord: Attempting to connect to /run/user/1000/discord-ipc-0
[DEBG] root: Switching to state SS14.Client.State.States.MainScreen
[INFO] discord: Connected to /run/user/1000/discord-ipc-0
[INFO] discord: Handling Response. Cmd: Dispatch, Event: Ready
[INFO] discord: Connection established with the RPC
[INFO] discord: Connected to discord with user User
[INFO] discord: Handling Response. Cmd: SetActivity, Event: 
[INFO] discord: Presence has been updated! 
[INFO] discord: Handling Response. Cmd: SetActivity, Event: 
[INFO] discord: Presence has been updated! 
GeneUNCG commented 4 years ago

I'm getting the same issue on Windows 10 as well.

ERR : Failed connection to discord-ipc-0. Access to the path is denied.
WARN: Tried to close a already closed pipe.
ERR : Failed connection to discord-ipc-1. The operation has timed out.
WARN: Tried to close a already closed pipe.

DiscordRichPresence version: 1.0.150 Newtonsoft.Json version: 12.0.3 Project's .NET Version: 4.8

Lachee commented 4 years ago

Are you running discord?