SignalR 2.2 connection issues. RRS feed

  • Question

  • User760824056 posted

    I  built a new project, a Windows Service, which includes a self-host, SignalR ( server.   This server app, as well as a client app,  was created with VS 2015, on a Windows 10 box (build 10586.318). 

    The client I mentioned is a UWP app, which includes a C# SignalR client (, designed to talk to the Windows Service.   I've created several similar apps in the past, with SignalR, and have not encountered this type of problem.     My client app will not connect to my server app.  Initially, I tested both apps on my development box, as I usually do with this type of application. 

    The client fails on the following, with an "An error occurred sending the request" message.

            public async void StartConnection()
                    await hubConn.Start();// hubConn is of type HubConnection
                catch (Exception Ex)
                    connectError  = Ex.Message;

    Below is the stack dump.

       at System.Net.Http.HttpClientHandler.<SendAsync>d__1.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 pmc.SignalRClient.ClientHubConnection.<StartConnection>d__13.MoveNext()

    The only major environment change I can think of, is the Windows 10 build version, of my development box.  I believe I was on build 10240 previously.    I thought that might be a factor, so I tried running my self-host, server app on a Windows 7 box but the result is the same.   I've tried a few different listening ports, above 10000, but same problem.   Something which I found strange, if I run netstat -a, on the box running my self host server, I don't see  the port I configured listed.

    Anyone else encountering this problem?  Thanks

    Tuesday, June 7, 2016 1:17 AM

All replies

  • User61956409 posted

    Hi EricO64,

    Firstly, you said you create other similar applications using SignalR and the applications work fine, I’d like to know if you install the same version (2.2.0) of Microsoft.AspNet.SignalR.Client NuGet package in your these applications. You could try to install earlier version Microsoft.AspNet.SignalR.Client NuGet package.


    Secondly, could you share us the code snippet of creating HubConnection object.

    Besides, the following link explained how to establish a connection, you could check it.


    Best Regards,

    Fei Han

    Wednesday, June 8, 2016 7:22 AM
  • User760824056 posted

    Thank you for the reply.

    Yes.  I've successfully created similar projects with SignalR 2.2.  With this particular project, I tried a C# UWP client as well as a JavaScript client, same failure.  I also tried SignalR 2.0.0 (host & client), no success.  During debugging, I looked at the exception thrown and found something about failing to negotiate or initialize a transport.  So, I attempted the following, with no luck.

    await hubConn.Start( new WebSocketTransport());

    await hubConn.Start( new LongPollingTransport());

    await hubConn.Start( new ServerSentEventsTransport());

    As requested, here is the code I use to create a hubconnection.  It's contained within the private constructor of a singleton class.

            private ClientHubConnection()
                hubConn = new HubConnection(url);
                hubConn.StateChanged += hubConn_StateChanged;

    After posting the above, I enabled tracing on the client side.

            private ClientHubConnection()
                tw = new StringWriter(sb);  //sb is an instance of StringBuilder
                hubConn = new HubConnection(url);
                hubConn.TraceLevel = TraceLevels.All;
                hubConn.TraceWriter = tw;
                hubConn.StateChanged += hubConn_StateChanged;

    At the point the call to HubConnection.Start() fails, with a thrown exception, the trace contains the following:

    {21:27:20.8811942 - null - ChangeState(Disconnected, Connecting)
    21:27:22.3317869 - null - Disconnected
    21:27:22.3322870 - null - Transport.Dispose()
    21:27:22.3327876 - null - Closed}

    Anyone know what the null represents?

    Thursday, June 9, 2016 7:33 PM
  • User760824056 posted

    After trying several different approaches,  I finally got my app working again.   My original client app was comprised of all UWP class libraries.   Using NuGet, I added SignalR to one of the solution's class library projects, via install-package Microsoft.AspNet.SignalR.Client.   This is what was installed:

      "dependencies": {
        "Microsoft.AspNet.SignalR.Client": "2.2.0",
        "Microsoft.NETCore.UniversalWindowsPlatform": "5.0.0"

    That was the configuration giving me the errors, I described in my original post.

    I looked at a UWP SignalR sample solution and noticed they were using  Universal Windows Portable.  So, I created a new Portable project and installed the Portable version of SignalR client.  I copied my code, verbatim, from my UWP project to the new portable project and I'm able to connect again.

    <package id="Microsoft.AspNet.SignalR.Client.Portable" version="2.0.1" targetFramework="portable45-net45+win8" />

    I'm not sure I'd call this a 'fix'. If it's documented somewhere that UWP apps require the 2.0.1 Portable version, instead of what I had, I missed it.

    Tuesday, June 14, 2016 12:03 AM