Xamarin Android & Websockets
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
I am trying to support websockets with signalR 6 on Android, with a Xamarin app, my code works as intended with longpolling, but there are clear benefits for me in using websockets, and I now have tried for a long time to make this work. But if I set supported transports to Websockets only in the client I get the error message that Longpolling is dissabled in the client, but the server does provide Longpolling,
Unable to connect to the server with any of the available transports. (WebSockets failed: Unable to connect to the remote server) (LongPolling failed: The transport is disabled by the client.)
My client, does look like this;
this._connection = new HubConnectionBuilder()
.WithUrl($"{_host}/rabbitHub?deviceId={id}", (opts) =>
{
opts.HttpMessageHandlerFactory = (x) => new HttpClientHandler
{
ServerCertificateCustomValidationCallback = HttpClientHandler.DangerousAcceptAnyServerCertificateValidator,
};
opts.AccessTokenProvider = () => Task.FromResult(authToken ?? "bypassauthplz");
opts.Transports = Microsoft.AspNetCore.Http.Connections.HttpTransportType.WebSockets /*| Microsoft.AspNetCore.Http.Connections.HttpTransportType.ServerSentEvents | Microsoft.AspNetCore.Http.Connections.HttpTransportType.LongPolling*/;
} )
.WithAutomaticReconnect()
.ConfigureLogging(logging =>
{
logging.SetMinimumLevel(LogLevel.Trace);
}).Build();
and the Server is configured like this:
services.AddSignalR().AddHubOptions<RabbitHub>(options => { options.MaximumParallelInvocationsPerClient = 32; options.KeepAliveInterval = new TimeSpan(0,0,0,5); options.ClientTimeoutInterval = new TimeSpan(0,0,0,10); });
endpoints.MapHub<RabbitHub>("/rabbitHub", options => { options.Transports = HttpTransportType.WebSockets | HttpTransportType.LongPolling | HttpTransportType.ServerSentEvents; });
Expected Behavior
The Expected behavior would be that the client would be aple to connect to the SignalR Server via websockets, this seems to be no Problem with Android, if I connect to an non signalR Websocket I with System.Net.WebSockets, everithing is working as intendet. So there has to be a bug in the Aspnet.core lib.
I'am using this lib with netstandard 2.1 for the client and .net6 for the server, but changing the server from 5 to 6 did not change anything.
Steps To Reproduce
I would like to provide a simple example, I will provide one as soon as I , find the time to Build one.
Exceptions (if any)
Unable to connect to the server with any of the available transports. (WebSockets failed: Unable to connect to the remote server) (LongPolling failed: The transport is disabled by the client.)
.NET Version
6
Anything else?
No response
if I connect to an non signalR Websocket I with System.Net.WebSockets, everithing is working as intendet.
SignalR uses System.Net.WebSockets so there shouldn't be any difference in behavior here.
Can you share how are you using System.Net.WebSockets outside of SignalR? Also, capture client and server logs please: https://docs.microsoft.com/aspnet/core/signalr/diagnostics?view=aspnetcore-6.0
Hi @SSpormann. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time.
@BrennanConroy
So, if I use Websockets as only transport, I get the above mentioned error,
Unable to connect to the server with any of the available transports. (WebSockets failed: Unable to connect to the remote server) (LongPolling failed: The transport is disabled by the client.)
And no Log on the server side, this seems to me like signalr is preventing the use of websockets by it self.
If I allow longpolling I get,
[Authorization, Bearer sometoken] [Host, myhost] [User-Agent, Microsoft SignalR/6.0 (6.0.3+c911002ab43b7b989ed67090f2a48d9073d5118d; Linux; .NET; Mono 6.12.0 (2020-02/adf1bc4335d))] [x-requested-with, XMLHttpRequest] [x-forwarded-proto, https] 2022-05-27 08:04:48.4049||DEBUG|AuthService.AuthenticationHandlers.EpasAuthenticationHandler|Bypassing auth for /myHub: /myHub 2022-05-27 08:04:48.4049|8|DEBUG|AuthService.AuthenticationHandlers.EpasAuthenticationHandler|AuthenticationScheme: EpasAuth was successfully authenticated. 2022-05-27 08:04:48.4094|4|DEBUG|Microsoft.AspNetCore.Http.Connections.Internal.HttpConnectionDispatcher|Establishing new connection. 2022-05-27 08:04:48.4094|5|DEBUG|Microsoft.AspNetCore.SignalR.HubConnectionHandler|OnConnectedAsync started.
And the connection is working, from here on.
I used this example to validate that the concept should in theory work,
https://devblogs.microsoft.com/xamarin/developing-real-time-communication-apps-with-websocket/
(You will have to Update some/all nuget packages to make it work)
Maybe it has something to do with teh setup of my project, the client is currently in a netstandard 2.1 project that I referenced in my project, beacause we are using the same client on multiple platforms.
If I use the same client under WPF, with only transport Websocket, every thing works fine.
I can now provide a sample that shows a working version with playn websockets, and a version that is working with signalr Longpolling enabled and is not working with signalr only using websockets on the client side.
You can finde the project here:
If you prefere an other methode to recieve the sample please, contact me we can figure something out.
To use the sample there is a solution under the folder easychat, there should be two Xamarin projects inside, one is called MyEasyChat, this is using plain websockets, combine this project with the server in the folder myeasychat und you can see that the concept of using websockets with System.Net.WebSockets does work. If you now want to try the faulty projekt, you have to use the project SignalRMyEasyChat under the EasyChat.sln and combine this with the myeasychat-signalr server under the folder with tehe same name(myeasychat-signalr) this, should currently promt the same error as I provided earlier.
Unable to connect to the server with any of the available transports. (WebSockets failed: Unable to connect to the remote server) (LongPolling failed: The transport is disabled by the client.)
if you now change the line of code in the EasyChat.sln -> SignalRMyEasyChat -> ChatPageViewModel line: 41
From:
opts.Transports = Microsoft.AspNetCore.Http.Connections.HttpTransportType.WebSockets /*| Microsoft.AspNetCore.Http.Connections.HttpTransportType.ServerSentEvents | Microsoft.AspNetCore.Http.Connections.HttpTransportType.LongPolling*/;
To:
opts.Transports = Microsoft.AspNetCore.Http.Connections.HttpTransportType.WebSockets | Microsoft.AspNetCore.Http.Connections.HttpTransportType.ServerSentEvents | Microsoft.AspNetCore.Http.Connections.HttpTransportType.LongPolling;
you should see that Signal-R is indeed working, but it does not work with websockets as transport.
you will have to change the IP-Adresses, in the ChatPageViewModel files, to your Server-IP.
I would investigate this problem further by my self but, currently I have no Idea how to setup the aspnet core repository in a way, that I would be able to debug this problem, I tried to setup a debug environment a year ago and stoped trying after 2 days. If someone has a guide on how to debug the aspnet.core project that would help me out a great deal.
I allso tryed to capture network traffic, from the phone to the server and as I suspected earlier, there is not even a connection request exiting the device, so I belive ther must be a logic error that throws the exception client side.
Please provide the repro app as a github repository.
@BrennanConroy here you go.
@SSpormann is it private? It says not found.
@BrennanConroy sorry should be public now
Unrelated: https://github.com/SSpormann/EasyChat-SignalR/blob/afb56ae1a2b5c00a2d8d4f445688c7f6a3012772/myeasychat-signalr/myeasychat-signalr/Program.cs#L15
Why would you allow the client to send a message of 1GB? That's a potential security issue.
Also unrelated, sent a clean up PR https://github.com/SSpormann/EasyChat-SignalR/pull/1
@SSpormann can you remove specifying all of the transports from both the client and server?
@davidfowl No thats the point of the sample, i want to use websocket transport, if i use longpolling it works, and if I remove the Settings from the client it falls back to longpolling
WebSockets is used by default, when nothing is specified. We're trying to understand why that isn't happening in this case.
So if i remove the transport overwrite from both, the client and the server it defaults to server sent events
trce: Microsoft.AspNetCore.SignalR.HubConnectionContext[3]
Sent a ping message to the client.
trce: Microsoft.AspNetCore.Http.Connections.Internal.Transports.ServerSentEventsTransport[1]
Great, so it's explicitly always skipping websockets. What server are you running this on?
In testing I use a Windows 10 mashine, but in production we use Ubuntu 20.04 lts and it shows the same behavior
Those are wildly different OSes, so before debugging, we should pick the relevant one and the one you have access to. Though since it happens on both I wonder if this is a client problem more than a server one.
What do the server side logs show when you try to connect?
As I mentioned earlyer in the post, I head a suspicion that this is a client problem if I define only Websocket transport on the client I don't get a request on the server, I allso tried to log the network traffic, but there was no request on the signalr port, so I figured the client side must have prevented the execution of the request.
so if I dont configure transport, I get
trce: Microsoft.AspNetCore.SignalR.HubConnectionContext[3]
Sent a ping message to the client.
trce: Microsoft.AspNetCore.Http.Connections.Internal.Transports.ServerSentEventsTransport[1]
If I do, specify websockets, I dont get anything.
This is the only thing that comes to mind https://github.com/dotnet/aspnetcore/blob/0af1274dea32a2103f383933b557c5ed2714d569/src/SignalR/clients/csharp/Http.Connections.Client/src/Internal/DefaultTransportFactory.cs#L44.
How easily can you debug first chance exceptions in Xamarin applications?
Does console logging work with Xamarin android? If yes, you should be able to use this package to add the console logger to the hubconnectionbuilder
I never tried this, without putting the source directly into my solution, but I dont know if i could link the pdb of the asp signalr project, this might work.
Yes the overwrite logging should work.
@SSpormann Lets go with the client side logging for now. That should suffice.
This is unconfigured
Loaded assembly: /data/data/com.companyname.signalrmyeasychat/files/.__override__/System.Net.Http.dll [External] Loaded assembly: /data/data/com.companyname.signalrmyeasychat/files/.__override__/System.Memory.dll [External] Loaded assembly: /data/data/com.companyname.signalrmyeasychat/files/.__override__/System.Buffers.dll [External] Thread started: Console logger queue processing thread #2 Resolved pending breakpoint at 'ChatPageViewModel.cs:97,1' to void SignalRMyEasyChat.ChatPageViewModel.<ConnectToServerAsync>d__16.MoveNext () [0x000f8]. Resolved pending breakpoint at 'ChatPageViewModel.cs:92,1' to void SignalRMyEasyChat.ChatPageViewModel.<ConnectToServerAsync>d__16.MoveNext () [0x0004a]. <7>Microsoft.AspNetCore.SignalR.Client.HubConnection[40] Registering handler for client method 'send'. <7>Microsoft.AspNetCore.SignalR.Client.HubConnection[42] Waiting on Connection Lock in StartAsyncInner (/_/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs:247). <7>Microsoft.AspNetCore.SignalR.Client.HubConnection[80] The HubConnection is attempting to transition from the Disconnected state to the Connecting state. <7>Microsoft.AspNetCore.SignalR.Client.HubConnection[41] Starting HubConnection. <7>Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[1] Starting HttpConnection. <7>Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[8] Establishing connection with server at 'https://172.31.20.12:5001/EasyChatHub?deviceId=25a005e58875bbfa'. Thread started: #3 <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.LoggingHttpMessageHandler[1] Sending HTTP request POST 'https://172.31.20.12:5001/EasyChatHub/negotiate?deviceId=25a005e58875bbfa&negotiateVersion=1'. Thread started: <Thread Pool> #4 Thread started: <Thread Pool> #5 Thread started: <Thread Pool> #6 Thread started: <Thread Pool> #7 Thread started: <Thread Pool> #8 Thread started: <Thread Pool> #9 [Looper] PerfMonitor longMsg : seq=58 plan=08:46:42.695 late=16ms wall=6800ms running=706ms runnable=21ms binder=2ms h=android.view.ViewRootImpl$ViewRootHandler c=android.view.View$PerformClick procState=2 [Choreographer] Skipped 407 frames! The application may be doing too much work on its main thread. [Looper] PerfMonitor doFrame : time=10ms vsyncFrame=797025 latency=6797ms procState=2 historyMsgCount=4 (msgIndex=1 wall=6800ms seq=58 running=706ms runnable=21ms binder=2ms late=16ms h=android.view.ViewRootImpl$ViewRootHandler c=android.view.View$PerformClick) [OpenGLRenderer] Davey! duration=6831ms; Flags=0, IntendedVsync=24365372127998, Vsync=24372155461060, OldestInputEvent=9223372036854775807, NewestInputEvent=0, HandleInputStart=24372169461587, AnimationStart=24372169465857, PerformTraversalsStart=24372169765180, DrawStart=24372176263722, SyncQueued=24372178766118, SyncStart=24372179458357, IssueDrawCommandsStart=24372179527368, SwapBuffers=24372203024191, FrameCompleted=24372204327368, DequeueBufferDuration=243490, QueueBufferDuration=458073, GpuCompleted=0, Thread started: <Thread Pool> #10 Thread started: <Thread Pool> #11 Loaded assembly: /data/data/com.companyname.signalrmyeasychat/files/.__override__/System.Numerics.Vectors.dll [External] Loaded assembly: /data/data/com.companyname.signalrmyeasychat/files/.__override__/System.Runtime.CompilerServices.Unsafe.dll [External] <7>Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[9] Established connection 'njSkUc0x9n2uwiOpCtGhnw' with the server. <7>Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[7] Starting transport 'WebSockets' with Url: https://172.31.20.12:5001/EasyChatHub?deviceId=25a005e58875bbfa. <6>Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[1] Starting transport. Transfer mode: Text. Url: 'wss://172.31.20.12:5001/EasyChatHub?deviceId=25a005e58875bbfa&id=YH4JQg3nM4uhdlEVbcXbHw'. <3>Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[11] Failed to start connection. Error starting transport 'WebSockets'. System.Net.WebSockets.WebSocketException (0x80004005): Unable to connect to the remote server ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> Mono.Btls.MonoBtlsException: Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/boringssl/ssl/handshake_client.c:1132 at Mono.Btls.MonoBtlsContext.ProcessHandshake () [0x00042] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Btls/MonoBtlsContext.cs:220 at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status, System.Boolean renegotiate) [0x000da] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:715 at (wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake(Mono.Net.Security.AsyncOperationStatus,bool) at Mono.Net.Security.AsyncHandshakeRequest.Run (Mono.Net.Security.AsyncOperationStatus status) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs:289 at Mono.Net.Security.AsyncProtocolRequest.ProcessOperation (System.Threading.CancellationToken cancellationToken) [0x000fc] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs:223 --- End of inner exception stack trace --- at Mono.Net.Security.MobileAuthenticatedStream.ProcessAuthentication (System.Boolean runSynchronously, Mono.Net.Security.MonoSslAuthenticationOptions options, System.Threading.CancellationToken cancellationToken) [0x0025c] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:310 at System.Net.WebSockets.WebSocketHandle.ConnectAsyncCore (System.Uri uri, System.Threading.CancellationToken cancellationToken, System.Net.WebSockets.ClientWebSocketOptions options) [0x0014f] 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:106 at System.Net.WebSockets.WebSocketHandle.ConnectAsyncCore (System.Uri uri, System.Threading.CancellationToken cancellationToken, System.Net.WebSockets.ClientWebSocketOptions options) [0x00385] 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:150 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 Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport.DefaultWebSocketFactory (Microsoft.AspNetCore.Http.Connections.Client.WebSocketConnectionContext context, System.Threading.CancellationToken cancellationToken) [0x003a7] in <d026f2adb6344ee59c6b7ee83a4fa858>:0 at System.Threading.Tasks.ValueTask1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport.StartAsync (System.Uri url, Microsoft.AspNetCore.Connections.TransferFormat transferFormat, System.Threading.CancellationToken cancellationToken) [0x00119] in 1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport.StartAsync (System.Uri url, Microsoft.AspNetCore.Connections.TransferFormat transferFormat, System.Threading.CancellationToken cancellationToken) [0x00119] in <d026f2adb6344ee59c6b7ee83a4fa858>:0 at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.StartTransport (System.Uri <7>Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[8] Establishing connection with server at 'https://172.31.20.12:5001/EasyChatHub?deviceId=25a005e58875bbfa'. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.LoggingHttpMessageHandler[1] Sending HTTP request POST 'https://172.31.20.12:5001/EasyChatHub/negotiate?deviceId=25a005e58875bbfa&negotiateVersion=1'. <7>Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[9] Established connection 'FC86Tlr0WfCGY6rbEfZ4SQ' with the server. <7>Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[7] Starting transport 'ServerSentEvents' with Url: https://172.31.20.12:5001/EasyChatHub?deviceId=25a005e58875bbfa. <6>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[1] Starting transport. Transfer mode: Text. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.LoggingHttpMessageHandler[1] Sending HTTP request GET 'https://172.31.20.12:5001/EasyChatHub?deviceId=25a005e58875bbfa&id=Mzpn-gh-t9OxVaZM2ENdUA'. Loaded assembly: /data/data/com.companyname.signalrmyeasychat/files/.__override__/System.Threading.Tasks.Extensions.dll [External] <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[3] Starting receive loop. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[9] Received 3 bytes. Parsing SSE frame. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[100] Starting the send loop. <7>Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[18] Transport 'ServerSentEvents' started. <6>Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[3] HttpConnection Started. <6>Microsoft.AspNetCore.SignalR.Client.HubConnection[24] Using HubProtocol 'json v1'. <7>Microsoft.AspNetCore.SignalR.Client.HubConnection[28] Sending Hub Handshake. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[103] Sending 32 bytes to the server using url: https://172.31.20.12:5001/EasyChatHub?deviceId=25a005e58875bbfa&id=Mzpn-gh-t9OxVaZM2ENdUA. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.LoggingHttpMessageHandler[1] Sending HTTP request POST 'https://172.31.20.12:5001/EasyChatHub?deviceId=25a005e58875bbfa&id=Mzpn-gh-t9OxVaZM2ENdUA'. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[104] Message(s) sent successfully. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[9] Received 6 bytes. Parsing SSE frame. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[9] Received 9 bytes. Parsing SSE frame. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[9] Received 11 bytes. Parsing SSE frame. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[9] Received 2 bytes. Parsing SSE frame. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[7] Passing message to application. Payload size: 3. <7>Microsoft.AspNetCore.SignalR.Client.HubConnection[39] Handshake with server complete. <7>Microsoft.AspNetCore.SignalR.Client.HubConnection[59] Sending PingMessage message. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[103] Sending 11 bytes to the server using url: https://172.31.20.12:5001/EasyChatHub?deviceId=25a005e58875bbfa&id=Mzpn-gh-t9OxVaZM2ENdUA. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.LoggingHttpMessageHandler[1] Sending HTTP request POST 'https://172.31.20.12:5001/EasyChatHub?deviceId=25a005e58875bbfa&id=Mzpn-gh-t9OxVaZM2ENdUA'. <7>Microsoft.AspNetCore.SignalR.Client.HubConnection[60] Sending PingMessage message completed. <7>Microsoft.AspNetCore.SignalR.Client.HubConnection[47] Receive loop starting. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[104] Message(s) sent successfully. <6>Microsoft.AspNetCore.SignalR.Client.HubConnection[44] HubConnection started. <7>Microsoft.AspNetCore.SignalR.Client.HubConnection[80] The HubConnection is attempting to transition from the Connecting state to the Connected state. <7>Microsoft.AspNetCore.SignalR.Client.HubConnection[20] Releasing Connection Lock in StartAsyncInner (/_/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs:280). <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[9] Received 6 bytes. Parsing SSE frame. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[9] Received 17 bytes. Parsing SSE frame. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[9] Received 19 bytes. Parsing SSE frame. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[9] Received 2 bytes. Parsing SSE frame. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[7] Passing message to application. Payload size: 11. <7>Microsoft.AspNetCore.SignalR.Client.HubConnection[56] Processing 11 byte message from server. <7>Microsoft.AspNetCore.SignalR.Client.HubConnection[26] Resetting keep-alive timer, received a message from the server. <7>Microsoft.AspNetCore.SignalR.Client.HubConnection[31] Received a ping message. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[9] Received 6 bytes. Parsing SSE frame. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[9] Received 17 bytes. Parsing SSE frame. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[9] Received 19 bytes. Parsing SSE frame. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[9] Received 2 bytes. Parsing SSE frame. <7>Microsoft.AspNetCore.Http.Connections.Client.Internal.ServerSentEventsTransport[7] Passing message to application. Payload size: 11. <7>Microsoft.AspNetCore.SignalR.Client.HubConnection[56] Processing 11 byte message from server. <7>Microsoft.AspNetCore.SignalR.Client.HubConnection[26] Resetting keep-alive timer, received a message from the server. <7>Microsoft.AspNetCore.SignalR.Client.HubConnection[31] Received a ping message.
this is configured with websockets only
<7>Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[9] Established connection '5rvTPvZvxlok8Ex2-ngYCw' with the server. <7>Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[7] Starting transport 'WebSockets' with Url: https://172.31.20.12:5001/EasyChatHub?deviceId=25a005e58875bbfa. <6>Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport[1] Starting transport. Transfer mode: Text. Url: 'wss://172.31.20.12:5001/EasyChatHub?deviceId=25a005e58875bbfa&id=TI2rtRdNFM-sQE_hy8h0Eg'. <3>Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[11] Failed to start connection. Error starting transport 'WebSockets'. System.Net.WebSockets.WebSocketException (0x80004005): Unable to connect to the remote server ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> Mono.Btls.MonoBtlsException: Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/boringssl/ssl/handshake_client.c:1132 at Mono.Btls.MonoBtlsContext.ProcessHandshake () [0x00042] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Btls/MonoBtlsContext.cs:220 at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status, System.Boolean renegotiate) [0x000da] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:715 at (wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake(Mono.Net.Security.AsyncOperationStatus,bool) at Mono.Net.Security.AsyncHandshakeRequest.Run (Mono.Net.Security.AsyncOperationStatus status) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs:289 at Mono.Net.Security.AsyncProtocolRequest.ProcessOperation (System.Threading.CancellationToken cancellationToken) [0x000fc] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs:223 --- End of inner exception stack trace --- at Mono.Net.Security.MobileAuthenticatedStream.ProcessAuthentication (System.Boolean runSynchronously, Mono.Net.Security.MonoSslAuthenticationOptions options, System.Threading.CancellationToken cancellationToken) [0x0025c] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:310 at System.Net.WebSockets.WebSocketHandle.ConnectAsyncCore (System.Uri uri, System.Threading.CancellationToken cancellationToken, System.Net.WebSockets.ClientWebSocketOptions options) [0x0014f] 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:106 at System.Net.WebSockets.WebSocketHandle.ConnectAsyncCore (System.Uri uri, System.Threading.CancellationToken cancellationToken, System.Net.WebSockets.ClientWebSocketOptions options) [0x00385] 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:150 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 Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport.DefaultWebSocketFactory (Microsoft.AspNetCore.Http.Connections.Client.WebSocketConnectionContext context, System.Threading.CancellationToken cancellationToken) [0x003a7] in <d026f2adb6344ee59c6b7ee83a4fa858>:0 at System.Threading.Tasks.ValueTask1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport.StartAsync (System.Uri url, Microsoft.AspNetCore.Connections.TransferFormat transferFormat, System.Threading.CancellationToken cancellationToken) [0x00119] in 1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport.StartAsync (System.Uri url, Microsoft.AspNetCore.Connections.TransferFormat transferFormat, System.Threading.CancellationToken cancellationToken) [0x00119] in <d026f2adb6344ee59c6b7ee83a4fa858>:0 at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.StartTransport (System.Uri <7>Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[14] Skipping transport ServerSentEvents because it was disabled by the client. <7>Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[14] Skipping transport LongPolling because it was disabled by the client. <7>Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[5] Skipping dispose, connection is already disposed. <7>Microsoft.AspNetCore.SignalR.Client.HubConnection[80] The HubConnection is attempting to transition from the Connecting state to the Disconnected state. <7>Microsoft.AspNetCore.SignalR.Client.HubConnection[20] Releasing Connection Lock in StartAsyncInner (/_/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs:280). Signalr connect failed System.AggregateException: Unable to connect to the server with any of the available transports. (WebSockets failed: Unable to connect to the remote server) (ServerSentEvents failed: The transport is disabled by the client.) (LongPolling failed: The transport is disabled by the client.) ---> Microsoft.AspNetCore.Http.Connections.Client.TransportFailedException: WebSockets failed: Unable to connect to the remote server ---> System.Net.WebSockets.WebSocketException: Unable to connect to the remote server ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> Mono.Btls.MonoBtlsException: Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/boringssl/ssl/handshake_client.c:1132 at Mono.Btls.MonoBtlsContext.ProcessHandshake () [0x00042] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Btls/MonoBtlsContext.cs:220 at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status, System.Boolean renegotiate) [0x000da] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:715 at (wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake(Mono.Net.Security.AsyncOperationStatus,bool) at Mono.Net.Security.AsyncHandshakeRequest.Run (Mono.Net.Security.AsyncOperationStatus status) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs:289 at Mono.Net.Security.AsyncProtocolRequest.ProcessOperation (System.Threading.CancellationToken cancellationToken) [0x000fc] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs:223 --- End of inner exception stack trace --- at Mono.Net.Security.MobileAuthenticatedStream.ProcessAuthentication (System.Boolean runSynchronously, Mono.Net.Security.MonoSslAuthenticationOptions options, System.Threading.CancellationToken cancellationToken) [0x0025c] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:310 at System.Net.WebSockets.WebSocketHandle.ConnectAsyncCore (System.Uri uri, System.Threading.CancellationToken cancellationToken, System.Net.WebSockets.ClientWebSocketOptions options) [0x0014f] 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:106 --- End of inner exception stack trace --- at System.Net.WebSockets.WebSocketHandle.ConnectAsyncCore (System.Uri uri, System.Threading.CancellationToken cancellationToken, System.Net.WebSockets.ClientWebSocketOptions options) [0x00385] 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:150 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 Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport.DefaultWebSocketFactory (Microsoft.AspNetCore.Http.Connections.Client.WebSocketConnectionContext context, System.Threading.CancellationToken cancellationToken) [0x003a7] in <d026f2adb6344ee59c6b7ee83a4fa858>:0 at System.Threading.Tasks.ValueTask1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813
at Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport.StartAsync (System.Uri url, Microsoft.AspNetCore.Connections.TransferFormat transferFormat, System.Threading.CancellationToken cancellationToken) [0x00119] in 1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813 at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncCore (System.Threading.CancellationToken cancellationToken) [0x000a9] in <fe6fb5de191d46d2bb2adcc855b27710>:0 at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncInner (System.Threading.CancellationToken cancellationToken) [0x001a3] in <fe6fb5de191d46d2bb2adcc855b27710>:0 at System.Threading.Tasks.ForceAsyncAwaiter.GetResult () [0x0000c] in <fe6fb5de191d46d2bb2adcc855b27710>:0 at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsync (System.Threading.CancellationToken cancellationToken) [0x00091] in <fe6fb5de191d46d2bb2adcc855b27710>:0 at SignalRMyEasyChat.ChatPageViewModel.ConnectToServerAsync () [0x00069] in C:\Users\sspormann\Desktop\easychat-service\EasyChat-SignalR\SignalRMyEasyChat\SignalRMyEasyChat\ChatPageViewModel.cs:92 ---> (Inner Exception #0) Microsoft.AspNetCore.Http.Connections.Client.TransportFailedException: WebSockets failed: Unable to connect to the remote server ---> System.Net.WebSockets.WebSocketException: Unable to connect to the remote server ---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. ---> Mono.Btls.MonoBtlsException: Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/boringssl/ssl/handshake_client.c:1132 at Mono.Btls.MonoBtlsContext.ProcessHandshake () [0x00042] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Btls/MonoBtlsContext.cs:220 at Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status, System.Boolean renegotiate) [0x000da] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:715 at (wrapper remoting-invoke-with-check) Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake(Mono.Net.Security.AsyncOperationStatus,bool) at Mono.Net.Security.AsyncHandshakeRequest.Run (Mono.Net.Security.AsyncOperationStatus status) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs:289 at Mono.Net.Security.AsyncProtocolRequest.ProcessOperation (System.Threading.CancellationToken cancellationToken) [0x000fc] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/AsyncProtocolRequest.cs:223 --- End of inner exception stack trace --- at Mono.Net.Security.MobileAuthenticatedStream.ProcessAuthentication (System.Boolean runSynchronously, Mono.Net.Security.MonoSslAuthenticationOptions options, System.Threading.CancellationToken cancellationToken) [0x0025c] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:310 at System.Net.WebSockets.WebSocketHandle.ConnectAsyncCore (System.Uri uri, System.Threading.CancellationToken cancellationToken, System.Net.WebSockets.ClientWebSocketOptions options) [0x0014f] 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:106 --- End of inner exception stack trace --- at System.Net.WebSockets.WebSocketHandle.ConnectAsyncCore (System.Uri uri, System.Threading.CancellationToken cancellationToken, System.Net.WebSockets.ClientWebSocketOptions options) [0x00385] 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:150 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 Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport.DefaultWebSocketFactory (Microsoft.AspNetCore.Http.Connections.Client.WebSocketConnectionContext context, System.Threading.CancellationToken cancellationToken) [0x003a7] in <d026f2adb6344ee59c6b7ee83a4fa858>:0 at System.Threading.Tasks.ValueTask1[TResult].get_Result () [0x0001b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/corefx/src/Common/src/CoreLib/System/Threading/Tasks/ValueTask.cs:813
at Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport.StartAsync (System.Uri url, Microsoft.AspNetCore.Connections.TransferFormat transferFormat, System.Threading.CancellationToken cancellationToken) [0x00119] in
Seems like HTTPS is the problem? The error is right there:
Microsoft.AspNetCore.Http.Connections.Client.HttpConnection[11] Failed to start connection. Error starting transport 'WebSockets'.
System.Net.WebSockets.WebSocketException (0x80004005): Unable to connect to the remote server --->
System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception. --->
Mono.Btls.MonoBtlsException: Ssl error:1000007d:SSL routines:OPENSSL_internal:CERTIFICATE_VERIFY_FAILED at /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/boringssl/ssl/handshake_client.c:1132 at
Mono.Btls.MonoBtlsContext.ProcessHandshake () [0x00042] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Btls/MonoBtlsContext.cs:220 at
Mono.Net.Security.MobileAuthenticatedStream.ProcessHandshake (Mono.Net.Security.AsyncOperationStatus status, System.Boolean renegotiate) [0x000da] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/System/Mono.Net.Security/MobileAuthenticatedStream.cs:715 at (wrapper remoting-invoke-w
Yes i have seen the error, but the same seems to work with ather transports they should in theory use the same implementation of SSL as longpolling and serversendevents, but this must than be an issue of googles boringssl.
Try adding this to your client configuration:
opts.WebSocketConfiguration = o =>
{
o.RemoteCertificateValidationCallback = (a, b, c, d) =>
{
return true;
};
};
https://github.com/SSpormann/EasyChat-SignalR/blob/bd3d734da4fa378fbb93302bbbc3c14c289617b2/SignalRMyEasyChat/SignalRMyEasyChat/ChatPageViewModel.cs#L33
OR you can use HTTP instead of HTTPS.. 😄
This is the configuration I was using all the time because you use the developer certificate to run the sample. It still promts this error.
You need to configure both the http configuration and the websocket configuration. Try this and see if it works this time.
I don get the WebSocketConfiguration Is all I get exposed:
public X509CertificateCollection ClientCertificates { get; set; }
public CookieContainer Cookies { get; set; }
public ICredentials Credentials { get; set; }
public TimeSpan KeepAliveInterval { get; set; }
public IWebProxy Proxy { get; set; }
public bool UseDefaultCredentials { get; set; }
public void AddSubProtocol(string subProtocol);
public void SetBuffer(int receiveBufferSize, int sendBufferSize);
public void SetBuffer(int receiveBufferSize, int sendBufferSize, ArraySegment<byte> buffer);
public void SetRequestHeader(string headerName, string headerValue);
You don't see this property?