Lavalink logs "Connection established" despite connection failing
Created by: aPinat
Summary
The Lavalink extension logs Connection established
even when the connection to the Lavalink server fails.
Details
I believe this happens due to WebSocketClient
always triggering the Connected
event regardless of whether the connection is successful or not.
https://github.com/DSharpPlus/DSharpPlus/blob/f65d2e6100e37e1617381c9d9a4696e080f1d98d/DSharpPlus/Net/WebSocket/WebSocketClient.cs#L101
On .NET Core 3.1, D#+ 4.0.0-nightly-00697, Windows 10 2004
Steps to reproduce
Try to connect to a non-existent Lavalink server and check log.
Discord.Ready += async e => Lavalink = await Discord.UseLavalink().ConnectAsync(new LavalinkConfiguration
{
Password = "youshallnotpass",
RestEndpoint = new ConnectionEndpoint("localhost", 2333),
SocketEndpoint = new ConnectionEndpoint("localhost", 2333)
});
Log output:
[2020-05-28 23:13:41 +02:00] [Lavalink] [Info] Connection established
[2020-05-28 23:13:41 +02:00] [DSharpPlus] [Error] An System.AggregateException occurred in READY.
System.AggregateException: Exceptions occured within one or more event handlers. Check InnerExceptions for details. (Unable to connect to the remote server)
---> System.Net.WebSockets.WebSocketException (0x80004005): Unable to connect to the remote server
---> System.Net.Http.HttpRequestException: No connection could be made because the target machine actively refused it.
---> System.Net.Sockets.SocketException (10061): No connection could be made because the target machine actively refused it.
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)