Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Websocket.Client.Exceptions.WebsocketException: Failed to start Websocket client, error: 'Unable to connect to the remote server' #14

Open
dinomov opened this issue Mar 30, 2021 · 5 comments

Comments

@dinomov
Copy link

dinomov commented Mar 30, 2021

Hi, I am getting this error 'Unable to connect to the remote server'

below full log

Websocket.Client.Exceptions.WebsocketException: Failed to start Websocket client, error: 'Unable to connect to the remote server' ---> System.Net.WebSockets.WebSocketException: Unable to connect to the remote server
  at System.Net.WebSockets.WebSocketHandle.ParseAndValidateConnectResponseAsync (System.IO.Stream stream, System.Net.WebSockets.ClientWebSocketOptions options, System.String expectedSecWebSocketAccept, System.Threading.CancellationToken cancellationToken) [0x00100] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/WebSocketHandle.Managed.cs:337
  at System.Net.WebSockets.WebSocketHandle.ConnectAsyncCore (System.Uri uri, System.Threading.CancellationToken cancellationToken, System.Net.WebSockets.ClientWebSocketOptions options) [0x00383] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/WebSocketHandle.Managed.cs:148
  at System.Net.WebSockets.ClientWebSocket.ConnectAsyncCore (System.Uri uri, System.Threading.CancellationToken cancellationToken) [0x000d1] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/ClientWebSocket.cs:157
  at Websocket.Client.WebsocketClient+<>c.<.ctor>b__17_0 (System.Uri uri, System.Threading.CancellationToken token) [0x00094] in <2b50a17598de47ed81cba7c1da265155>:0
  at Websocket.Client.WebsocketClient.StartClient (System.Uri uri, System.Threading.CancellationToken token, Websocket.Client.ReconnectionType type, System.Boolean failFast) [0x000a0] in <2b50a17598de47ed81cba7c1da265155>:0
  --- End of inner exception stack trace ---
  at Websocket.Client.WebsocketClient.StartClient (System.Uri uri, System.Threading.CancellationToken token, Websocket.Client.ReconnectionType type, System.Boolean failFast) [0x001be] in <2b50a17598de47ed81cba7c1da265155>:0
  at Websocket.Client.WebsocketClient.StartInternal (System.Boolean failFast) [0x000f3] in <2b50a17598de47ed81cba7c1da265155>:0
  at Socket.Io.Client.Core.SocketIoClient.StartSocketAsync () [0x000fc] in <341c2fa490384af5b3ab61da0d70f46d>:0
  at Socket.Io.Client.Core.SocketIoClient.OpenAsync (System.Uri uri, Socket.Io.Client.Core.Model.SocketIoOpenOptions options) [0x001b6] in <341c2fa490384af5b3ab61da0d70f46d>:0
  at DialogEvent.Droid.Service.VideoMeeting.Signalling2.Start (System.Action`1[T] callback) [0x00103] in /Users/dinomov/projects/dialogevent/DialogEvent/DialogEvent.Droid/Service/VideoMeeting/Signalling2.cs:252
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021
  at Android.App.SyncContext+<>c__DisplayClass2_0.<Post>b__0 () [0x00000] in /Users/builder/azdo/_work/278/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:36
  at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in /Users/builder/azdo/_work/278/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36
  at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in /Users/builder/azdo/_work/278/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-29/mcw/Java.Lang.IRunnable.cs:84
  at at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.21(intptr,intptr)
@LadislavBohm
Copy link
Owner

This looks like you are trying to run it on Xamarin, is that correct? Are you able to connect to the server from standard .NET Core console application? Also are you able to access the socket.io server to see some logs there?
This looks like a generic error when either server is not running or not accessible.

@dinomov
Copy link
Author

dinomov commented Mar 31, 2021

@LadislavBohm yes it is xamarin app, I will try to run it from standard .NET console application to see if it works, I will comment here about result later.

we were using this https://github.com/Quobject/SocketIoClientDotNet socket.io client on our xamarin app, but it is really old and recently on Android it became not stable, this is why we are now considering other socket.io clients in C# for our Xamarin app. server side socket.io version is 1.7.4. what do you suggest?

@LadislavBohm
Copy link
Owner

I haven't tested the library on Xamarin at all so I can't really help with that. However if you have an access to server then it could help with debugging. For example in this library I am not doing a standard socket.io protocol resolution and go straight for websocket connection (no long polling support). I had no issues connecting like that to socket.io servers but you could check whether your server supports websockets.

@dinomov
Copy link
Author

dinomov commented Mar 31, 2021

please see attached sample console application, it give following error even such package is added

src.zip

Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Websocket.Client, Version=4.3.0.0, Culture=neutral,

@LadislavBohm
Copy link
Owner

Sorry for the delay, but when I test your code on Windows it runs fine except it doesn't connect to remote server with this error:
image

However I was not able to connect to your server even from javascript client so I would recommend to first verify that it works from JS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants