WebSocketException on SignalR server when HubConnection.Stop() is called from the client

4

I am creating a web app using ASP.Net that is utilizing SignalR for client communication.

Whenever my client side code attempts to Close a HubConnection instance, using either the .Stop() method or wrapping the HubConnection in a using block, the server starts throwing System.Net.WebSockets.WebSocketsExceptions.

My server is being hosted by Visual Studio using IIS Express, and I have tried client code in both Linqpad and as a stand-alone exe. Both clients produced the same server exceptions.

My client side code (with unnecessary details removed) looks like this

async Task Main()
{
    var signalServerLocation = "http://localhost:5462/signalr";

    using (var hubConnection = new HubConnection(signalServerLocation))
    {
        await hubConnection.Start();
    }
}

The exception that gets raised looks like this

System.Net.WebSockets.WebSocketException occurred
  HResult=0x800703E3
  Message=The I/O operation has been aborted because of either a thread exit or an application request
  Source=System.Web

with a stack trace of

at System.Web.WebSockets.WebSocketPipe.<>c__DisplayClass9_0.<ReadFragmentAsync>b__0(Int32 hrError, Int32 cbIO, Boolean fUtf8Encoded, Boolean fFinalFragment, Boolean fClose)

This exception is non-fatal so it doesn't crash my server, but continuing through it leads to more exceptions of the same type being thrown, as well as System.OperationCancelledExceptions with the description of The operation was cancelled.

I've searched around a bit but couldn't find a straight answer as to why this happens.

So my question is this. Is there something I can do to stop these Exceptions from being thrown, or are they expected? Is there a problem with the way I am connecting?

c#
asp.net
signalr
signalr.client
asked on Stack Overflow Sep 15, 2017 by Isaac Zais

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0