Aspnetcore: Signalr Xamarin Client Disconnected when receiving group messages every 1 seconds

Created on 29 Mar 2019  ·  24Comments  ·  Source: dotnet/aspnetcore

Describe the bug

Signalr Client disconnect in Xamarin (iOS and Android) after a while when receiving a group message every 1 second

We developed test signalr client in C# that sends message to a group every 1 seconds

  • Messages are delivered successful in both Xamarin clients
  • After 2 or 3 minutes both Xamarin clients are disconnected while receiving messages for no reason
  • Test client written in C# and wpf is connected and has no issue at all.

To Reproduce

Steps to reproduce the behavior:

  1. Using this version of ASP.NET Core '2.2'
  2. Run this code in the server
    await Clients.OthersInGroup(msg.GroupId).SendAsync(ClientMethod.ON_GROUP_MESSAGE, protoclMessage);
  1. With these arguments
    small json object

  2. See error

    Error

The remote party closed the WebSocket connection without completing the close handshake.

Stacktrace

 at System.Net.WebSockets.ManagedWebSocket+<ReceiveAsyncPrivate>d__62`2[TWebSocketReceiveResultGetter,TWebSocketReceiveResult].MoveNext () [0x006e0] in <fb6d78e506844b3b96d5b35aa047fbbd>:0 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport+<StartReceiving>d__19.MoveNext () [0x0009d] in <843c441fa9954906b53e3710152bebb9>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.IO.Pipelines.PipeCompletion.ThrowLatchedException () [0x00000] in <285d42c15ab1455ca31b0389730dcae1>:0 
  at System.IO.Pipelines.PipeCompletion.IsCompletedOrThrow () [0x00012] in <285d42c15ab1455ca31b0389730dcae1>:0 
  at System.IO.Pipelines.Pipe.GetReadResult (System.IO.Pipelines.ReadResult& result) [0x00000] in <285d42c15ab1455ca31b0389730dcae1>:0 
  at System.IO.Pipelines.Pipe.GetReadAsyncResult () [0x0002b] in <285d42c15ab1455ca31b0389730dcae1>:0 
  at System.IO.Pipelines.Pipe+DefaultPipeReader.GetResult (System.Int16 token) [0x00000] in <285d42c15ab1455ca31b0389730dcae1>:0 
  at System.Threading.Tasks.ValueTask`1[TResult].get_Result () [0x00030] in <1d288dd8ebaf4c6f890e1e99a5a184f0>:0 
  at System.Runtime.CompilerServices.ValueTaskAwaiter`1[TResult].GetResult () [0x00000] in <1d288dd8ebaf4c6f890e1e99a5a184f0>:0 
  at Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport+<StartReceiving>d__19.MoveNext () [0x00200] in <843c441fa9954906b53e3710152bebb9>:0

Expected behavior

Xamarin Clients should not disconnected

Additional context

Clients SignalR Version

<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="1.1.0" />

Include the output of dotnet --info
Microsoft.NETCore.App 2.2.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

accepted area-signalr bug

Most helpful comment

Thanks guys

we want to see the Signalr to be the best cross platform websocket protocol ever exist

All 24 comments

Update

When we switched to AddMessagePackProtocol in both client and server seems the problem solved.

Maybe from Json that lock the connection somehow

Note: the message size is in between 60 bytes and 200 bytes

Can you provide a sample application that illustrates the problem? We're not seeing this kind of behavior in our Xamarin test apps.

The remote party closed the WebSocket connection without completing the close handshake.

This error occurs on the server whenever a client disconnects without properly shutting down. An intermediate proxy can cause this, or if your client app crashes.

The remote party closed the WebSocket connection without completing the close handshake.

Are you still receiving messages after seeing this error? Are you restarting the connection?

I just run the test again and remove .AddMessagePackProtocol() from xamarin client and the issue appeared again.

After disconnect the client stop receiving message and
I did not restarting the connection nor any exception thrown in the xamarin client except
The remote party closed the WebSocket connection without completing the close handshake.

Server

on the server the method OnDisconnectedAsync get fired with null Exception object

The class I am sending is nested class see below after serialized

{
  "Id": "ca41e7d1-43e9-4b71-868c-f217145cacc8",
  "From": {
    "Id": "0dfa392f-fac8-4a84-888a-f88a2f46b59e",
    "Name": "Norra",
    "Username": "@churchhg4991435"
  },
  "AffectedMember": null,
  "Date": "2019-04-10T14:49:30.975669Z",
  "GroupId": "6bf93ce8-83df-4b54-b86a-300f0a7021a2",
  "Body": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard",
  "MessageType": 0
}

Body is a random message between 5 and 25 length

Server Method

image

Client Method

image

Android http config

image

Note

When I switch back to .AddMessagePackProtocol() the xamarin client never get disconnected

Do you have any server or client logs when this happens?

https://docs.microsoft.com/en-us/aspnet/core/signalr/diagnostics?view=aspnetcore-2.2

Find below the server log when xamarin client is disconnected

dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "12", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "13", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "14", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "15", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "16", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "17", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "18", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.Http.Connections.Internal.Transports.WebSocketsTransport[4]
      Waiting for the application to finish sending data.
dbug: Microsoft.AspNetCore.Http.Connections.Internal.Transports.WebSocketsTransport[2]
      Socket closed.
dbug: Microsoft.AspNetCore.SignalR.HubConnectionHandler[6]
      OnConnectedAsync ending.
dbug: Microsoft.AspNetCore.Http.Connections.Internal.HttpConnectionManager[2]
      Removing connection ZpzNvb1sJ86Rwldr3pDheQ from the list of connections.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
      Request finished in 13296.5768ms 101
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "19", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "20", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "21", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "22", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "23", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "24", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "25", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "26", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "27", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "28", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "29", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "30", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "31", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "32", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "33", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "34", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
      Received hub invocation: InvocationMessage { InvocationId: "35", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.

Seems there is not enough information when the xamarin client get disconected see line 4 it just close the socket
```
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
Received hub invocation: InvocationMessage { InvocationId: "17", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
Received hub invocation: InvocationMessage { InvocationId: "18", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.Http.Connections.Internal.Transports.WebSocketsTransport[4]
Waiting for the application to finish sending data.
dbug: Microsoft.AspNetCore.Http.Connections.Internal.Transports.WebSocketsTransport[2]
Socket closed.
dbug: Microsoft.AspNetCore.SignalR.HubConnectionHandler[6]
OnConnectedAsync ending.
dbug: Microsoft.AspNetCore.Http.Connections.Internal.HttpConnectionManager[2]
Removing connection ZpzNvb1sJ86Rwldr3pDheQ from the list of connections.
info: Microsoft.AspNetCore.Hosting.Internal.WebHost[2]
Request finished in 13296.5768ms 101
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
Received hub invocation: InvocationMessage { InvocationId: "19", Target: "SendGroupMessage", Arguments: [ SignalrTest.Common.ProtocolGroupMessage ] }.
dbug: Microsoft.AspNetCore.SignalR.Internal.DefaultHubDispatcher[1]
````

I will try to get client log also

Thanks

Xamarin Client Log

[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 391, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 391 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 470, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 470 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 482, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 482 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Receive loop stopped.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Send loop stopped.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Error: The server connection was terminated with an error.

System.Net.WebSockets.WebSocketException (0x80004005): The remote party closed the WebSocket connection without completing the close handshake. ---> System.Net.WebSockets.WebSocketException (0x80004005): An exception caused the WebSocket to enter the Aborted state. Please see the InnerException, if present, for more details.
  at System.Net.WebSockets.ManagedWebSocket+<CloseWithReceiveErrorAndThrowAsync>d__66.MoveNext () [0x000a3] in <fb6d78e506844b3b96d5b35aa047fbbd>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Net.WebSockets.ManagedWebSocket+<ReceiveAsyncPrivate>d__62`2[TWebSocketReceiveResultGetter,TWebSocketReceiveResult].MoveNext () [0x00657] in <fb6d78e506844b3b96d5b35aa047fbbd>:0 
  at System.Net.WebSockets.ManagedWebSocket+<ReceiveAsyncPrivate>d__62`2[TWebSocketReceiveResultGetter,TWebSocketReceiveResult].MoveNext () [0x006e0] in <fb6d78e506844b3b96d5b35aa047fbbd>:0 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport+<StartReceiving>d__19.MoveNext () [0x0009d] in <843c441fa9954906b53e3710152bebb9>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.IO.Pipelines.PipeCompletion.ThrowLatchedException () [0x00000] in <285d42c15ab1455ca31b0389730dcae1>:0 
  at System.IO.Pipelines.PipeCompletion.IsCompletedOrThrow () [0x00012] in <285d42c15ab1455ca31b0389730dcae1>:0 
  at System.IO.Pipelines.Pipe.GetReadResult (System.IO.Pipelines.ReadResult& result) [0x00000] in <285d42c15ab1455ca31b0389730dcae1>:0 
  at System.IO.Pipelines.Pipe.GetReadAsyncResult () [0x0002b] in <285d42c15ab1455ca31b0389730dcae1>:0 
  at System.IO.Pipelines.Pipe+DefaultPipeReader.GetResult (System.Int16 token) [0x00000] in <285d42c15ab1455ca31b0389730dcae1>:0 
  at System.Threading.Tasks.ValueTask`1[TResult].get_Result () [0x00030] in <1d288dd8ebaf4c6f890e1e99a5a184f0>:0 
  at System.Runtime.CompilerServices.ValueTaskAwaiter`1[TResult].GetResult () [0x00000] in <1d288dd8ebaf4c6f890e1e99a5a184f0>:0 
  at Microsoft.AspNetCore.SignalR.Client.HubConnection+<ReceiveLoop>d__62.MoveNext () [0x000d7] in <f381011e9b214489bcb373743f31ed9d>:0 
[0:] Microsoft.AspNetCore.Http.Connections.Client.HttpConnection: Debug: Disposing HttpConnection.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Information: Transport is stopping.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Transport stopped.
[0:] Microsoft.AspNetCore.Http.Connections.Client.HttpConnection: Information: HttpConnection Disposed.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Canceling all outstanding invocations.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Error: Connection is shutting down due to an error.

System.Net.WebSockets.WebSocketException (0x80004005): The remote party closed the WebSocket connection without completing the close handshake. ---> System.Net.WebSockets.WebSocketException (0x80004005): An exception caused the WebSocket to enter the Aborted state. Please see the InnerException, if present, for more details.
  at System.Net.WebSockets.ManagedWebSocket+<CloseWithReceiveErrorAndThrowAsync>d__66.MoveNext () [0x000a3] in <fb6d78e506844b3b96d5b35aa047fbbd>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.Net.WebSockets.ManagedWebSocket+<ReceiveAsyncPrivate>d__62`2[TWebSocketReceiveResultGetter,TWebSocketReceiveResult].MoveNext () [0x00657] in <fb6d78e506844b3b96d5b35aa047fbbd>:0 
  at System.Net.WebSockets.ManagedWebSocket+<ReceiveAsyncPrivate>d__62`2[TWebSocketReceiveResultGetter,TWebSocketReceiveResult].MoveNext () [0x006e0] in <fb6d78e506844b3b96d5b35aa047fbbd>:0 
--- End of stack trace from previous location where exception was thrown ---
  at Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport+<StartReceiving>d__19.MoveNext () [0x0009d] in <843c441fa9954906b53e3710152bebb9>:0 
--- End of stack trace from previous location where exception was thrown ---
  at System.IO.Pipelines.PipeCompletion.ThrowLatchedException () [0x00000] in <285d42c15ab1455ca31b0389730dcae1>:0 
  at System.IO.Pipelines.PipeCompletion.IsCompletedOrThrow () [0x00012] in <285d42c15ab1455ca31b0389730dcae1>:0 
  at System.IO.Pipelines.Pipe.GetReadResult (System.IO.Pipelines.ReadResult& result) [0x00000] in <285d42c15ab1455ca31b0389730dcae1>:0 
  at System.IO.Pipelines.Pipe.GetReadAsyncResult () [0x0002b] in <285d42c15ab1455ca31b0389730dcae1>:0 
  at System.IO.Pipelines.Pipe+DefaultPipeReader.GetResult (System.Int16 token) [0x00000] in <285d42c15ab1455ca31b0389730dcae1>:0 
  at System.Threading.Tasks.ValueTask`1[TResult].get_Result () [0x00030] in <1d288dd8ebaf4c6f890e1e99a5a184f0>:0 
  at System.Runtime.CompilerServices.ValueTaskAwaiter`1[TResult].GetResult () [0x00000] in <1d288dd8ebaf4c6f890e1e99a5a184f0>:0 
  at Microsoft.AspNetCore.SignalR.Client.HubConnection+<ReceiveLoop>d__62.MoveNext () [0x000d7] in <f381011e9b214489bcb373743f31ed9d>:0 
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Invoking the Closed event handler.

The "Waiting for the application to finish sending data" log indicates the server received a TCP FIN from the client. However, the WebSocketException from the client indicates it was the server that sent the FIN.

Do you have any network logs? Ideally, we would gather network traces from both the server and the client machines, since they're each blaming the other side of the connection for closing.

My guess is there's something between the client and server that's closing the connection. I'm not sure why calling .AddMessagePackProtocol() would fix it. Maybe whatever is closing the text-based JSON WebSocket connection doesn't touch binary MessagePack connections?

Could you include information about which server you are using (IIS, Kestrel, HttpSysServer, etc.) and if there are any proxies in between? Often a proxy can interfere with the WebSocket connection.

We are using Kesteral server directly and there is no any proxy used.

We run all on windows 10

  • Server
  • Test Client
  • Xamarin Client

and turned off windows firewall and still the issue exist

even when we run the test on another machine on different network same thing happen

@halter73 could be the size of the packet matter ?

after add AddMessagePackProtocol()

[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 400 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Binary, size: 296, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 296 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Binary, size: 351, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 351 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Binary, size: 306, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 306 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Binary, size: 377, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 377 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Binary, size: 367, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 367 byte message from server.

and json report this


[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 475, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 475 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 406, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 406 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 268, EndOfMessage: False.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 268 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 185, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 453 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 499, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 499 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 510, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 510 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 503, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 503 byte message from server.

Update

We did send a fixed message from test client as body and the disconnected happen more often

إذا أردت أن تسقط التفاحة هز الشجرة. أول العلم الصمت، والثاتي حسن الاستماع، والثالث الحفظ، والرباع العمل به، ;

and we observe the Xamarin client it disconnect after sending ping message from Xamarin see log below
perhaps from ping ? we are not sure

[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 446, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 446 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Sending PingMessage message.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Sending PingMessage message completed.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Received message from application. Payload size: 11.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 446, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 446 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Receive loop stopped.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Send loop stopped.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Error: The server connection was terminated with an error.

and another test


[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Sending PingMessage message.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Received message from application. Payload size: 11.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Sending PingMessage message completed.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
04-13 00:37:12.689 W/zygote  (12137): Checksum mismatch for dex base.apk
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 446, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 446 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
04-13 00:37:12.689 W/zygote  (12137): Checksum mismatch for dex base.apk
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 446, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 446 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Message received. Type: Text, size: 447, EndOfMessage: True.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Debug: Processing 447 byte message from server.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Receive loop stopped.
[0:] Microsoft.AspNetCore.Http.Connections.Client.Internal.WebSocketsTransport: Debug: Send loop stopped.
[0:] Microsoft.AspNetCore.SignalR.Client.HubConnection: Error: The server connection was terminated with an error.

Everything looks pretty normal in the client logs. Do you have any server logs?

If you have an app that can reliably repro the issue on different machines, we could take a look at it if you published it to a GitHub repository.

Also, do you know why the following was logged twice?

04-13 00:37:12.689 W/zygote  (12137): Checksum mismatch for dex base.apk

Yes I have sample app that cause the issue find repos url below

https://github.com/balbarak/signalr-test

The above repo contains 3 projects

  • Server
  • Xamarin Client (Android)
  • Test Client (Console app)

Make sure to change the URL in SignalrTest.Common.AppClient

I have no idea why is this reported twice
04-13 00:37:12.689 W/zygote (12137): Checksum mismatch for dex base.apk

Thanks

Removing the waiting label. We'll try to find time as soon as we can to take a look at the repo repro. Thanks!

@balbarak we'll take a look at the repro, thanks! We're wrapping up a milestone right now, so it may take a little bit but we'll see what we can figure out!

Thank you for the repro @balbarak!

We've taken a look and found a bug in the WebSockets implementation that Xamarin uses. We're currently talking to the team to see what can be done.

Switching to a tracking issue. @BrennanConroy can you post a link to any Xamarin issue that comes out of this?

Thanks guys

we want to see the Signalr to be the best cross platform websocket protocol ever exist

We've got engagement from Mono folks on the linked issue. Closing this since the issue lives in the Mono CoreFX implementation.

Acceptance checklist (check one item)

  • [ ] We decided not to take this fix.
  • [ ] The fix is tests-only.
  • [x] The fix contains product changes (check all items below).

    • [x] Relevant XML documentation comments for new public APIs are present.

    • [x] Narrative docs (docs.microsoft.com) are updated. (check one item below)



      • [ ] The change requires a new article. An issue with an outline has been filed here: [ISSUE LINK]


      • [ ] The change requires a change to an existing article. A docs PR with these changes is linked here: [PR LINK]


      • [x] The change requires no docs changes.



    • [x] Verification has been completed. (check one item below)



      • [ ] The change is in the shared framework and was verified against the following versions





        • SDK installer: [VERSION]



        • ASP.NET Core Runtime: [VERSION]



        • .NET Core Runtime: [VERSION]





      • [ ] The change is in an OOB NuGet/NPM/JAR package and was verified against the following version of that package: [PACKAGE ID] [VERSION]


      • [x] The change is in Mono/Xamarin: [16.2.0.63 (d16-2@559c0f212)]



Was this page helpful?
0 / 5 - 0 ratings

Related issues

clement911 picture clement911  ·  129Comments

barrytang picture barrytang  ·  89Comments

KerolosMalak picture KerolosMalak  ·  269Comments

radenkozec picture radenkozec  ·  114Comments

reduckted picture reduckted  ·  91Comments