C
Join ServerC#
help
✅ hi im experimenting with websocketsservers and clients.
VVeQox12/21/2022
Im currently running the server with nodejs and the client in c#.
My problem is that the Websocket.ConnectAsync just crashes without an exeption so i dont really know whats wrong.
The server is running on port 8080 on localhost.
My problem is that the Websocket.ConnectAsync just crashes without an exeption so i dont really know whats wrong.
The server is running on port 8080 on localhost.
VVeQox12/21/2022
im connecting to
"ws://localhost:8080"
which worked before but for some reason now just crashes the appVVeQox12/21/2022
private async Task<bool> Connect(Uri uri)
{
try
{
await WebSocket.ConnectAsync(uri, CancellationToken.None);
}
catch (Exception)
{
return false;
}
return true;
}
VVeQox12/21/2022
where uri is
new Uri("ws://localhost:8080")
VVeQox12/21/2022
fixed it by using this
VVeQox12/21/2022
WebSocket.ConnectAsync(uri, cancellationTokenSource.Token).Wait(cancellationTokenSource.Token);
VVeQox12/21/2022
dont know why this fixes it 🤷♂️