Lachee / discord-rpc-csharp

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

Error spam when discord is not available #142

Closed ttermeer-reboundcg closed 7 months ago

ttermeer-reboundcg commented 3 years ago

When Discord is not running, RpcConnection is actively trying to connect repeatedly causing errors to be reported.

On .Net :

Exception thrown: 'System.TimeoutException' in System.Core.dll
Failed connection to discord-ipc-0. The operation has timed out.
Tried to close a already closed pipe.
Exception thrown: 'System.TimeoutException' in System.Core.dll
Failed connection to discord-ipc-1. The operation has timed out.
Tried to close a already closed pipe.
Exception thrown: 'System.TimeoutException' in System.Core.dll
Failed connection to discord-ipc-2. The operation has timed out.

On Unity :

Failed: Lachee.IO.Exceptions.NamedPipeOpenException, An exception has occured while trying to open the pipe. Error Code: 2
Failed: Lachee.IO.Exceptions.NamedPipeOpenException, An exception has occured while trying to open the pipe. Error Code: 2
[...]
Failed: Lachee.IO.Exceptions.NamedPipeOpenException, An exception has occured while trying to open the pipe. Error Code: 2
Failed to connect for some reason.

Either the error should be only reported once or allow us to specify a max retry count to stop the RpcConnection from connecting endlessly

Lachee commented 3 years ago

It will attempt to connect on any of the 10 pipes Discord maybe available on. If you wish to handle this logging, you can do so by writting a custom logger.

It is an exception it caught, so it needs to be logged as such https://github.com/Lachee/discord-rpc-csharp/blob/master/DiscordRPC/IO/ManagedNamedPipeClient.cs#L159