System.Net.WebSockets.Client.Managed icon indicating copy to clipboard operation
System.Net.WebSockets.Client.Managed copied to clipboard

Unable to establish websocket connection with IP address.

Open DAshok7814 opened this issue 3 years ago • 1 comments

we are trying to establish a socket connection with DNS. we can able to establish a connection successfully, same way if we are trying to establish a connection with the Ip address we are getting errors like below

occuredSystem.Net.WebSockets.WebSocketException (0x80004005): Unable to connect to the remote server ---> System.Security.Authentication.AuthenticationException: The remote certificate is invalid according to the validation procedure. at System.Net.Security.SslState.InternalEndProcessAuthentication(LazyAsyncResult lazyResult) at System.Net.Security.SslState.EndProcessAuthentication(IAsyncResult result) at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult) at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task1 promise, Boolean requiresSynchronization) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() at System.Net.WebSockets.Managed.WebSocketHandle.<ConnectAsyncCore>d__24.MoveNext() at System.Net.WebSockets.Managed.WebSocketHandle.<ConnectAsyncCore>d__24.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() at System.Net.WebSockets.Managed.ClientWebSocket.<ConnectAsyncCore>d__16.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter.GetResult() at TestSocketCommunication.Program.EstablishingConnection() in C:\Users\310257816\Source\Repos\TestWebSocketClient\TestSockeCommunication\Program.cs:line 129

we have added the ceritifcatevalidationcallback like this ServicePointManager.ServerCertificateValidationCallback = delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; }; still we are getting above error. team kindly suggest is there any way to overcome this issue. we are using System.Net.WebSockets.Client.Managed library.

DAshok7814 avatar Jul 07 '22 10:07 DAshok7814

Team Any suggestion on how to ignore the certificate callback from the server on Managed Client WebSocket library?

DAshok7814 avatar Jul 11 '22 05:07 DAshok7814