websocket-client icon indicating copy to clipboard operation
websocket-client copied to clipboard

Cannot connect with server while other library connects

Open gregg95 opened this issue 2 years ago • 0 comments

Hello,

I am struggling with issue, getting error 'Cannot connect with remote server'

here are console logs:

Disconnection happened, type:
Websocket.Client.DisconnectionInfo
Nie można połączyć się z serwerem zdalnym //cannot connet to remote server
Error
   w System.Net.WebSockets.ClientWebSocket.<ConnectAsyncCore>d__21.MoveNext()
--- Koniec śladu stosu z poprzedniej lokalizacji, w której wystąpił wyjątek --- 
   w System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   w System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   w Websocket.Client.WebsocketClient.<>c.<<-ctor>b__17_0>d.MoveNext()
--- Koniec śladu stosu z poprzedniej lokalizacji, w której wystąpił wyjątek ---
   w System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   w System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   w Websocket.Client.WebsocketClient.<StartClient>d__68.MoveNext()

and there is code I am running (as simplest as possible)


 var url = new Uri("ws://{ip}:15000/WebSocket");
using (var client = new WebsocketClient(url))
            {
                client.Name = "AGenTK_API";
                client.ReconnectTimeout = TimeSpan.FromSeconds(30);
                client.ReconnectionHappened.Subscribe(type =>
                    Console.WriteLine($"Reconnection happened, type: {type}"));
                client.DisconnectionHappened.Subscribe(type =>
                    Console.WriteLine($"Disconnection happened, type: {Environment.NewLine}{type}{Environment.NewLine}{type.Exception.Message}{Environment.NewLine}{type.Type}{Environment.NewLine}{type.Exception.StackTrace}"));
                client.MessageReceived.Subscribe(msg => Console.WriteLine($"Message received: {msg}"));
                await client.Start();

what is interesting at the same time I can connect to this websocket server using other library (websocket-sharp) and I even checked connecting with javascript sockets, which also work.

What is wrong here?

gregg95 avatar Dec 16 '21 13:12 gregg95