1
votes

I've been developing a Web Service (C# WebAPI2) so can simply send messages using SignalR and then store the message transcript within a TSQL database. However, after moving the SignalR hubs within a class library I can't seem to access them now. I have developed a very simply console application to communicate with the Web Service but I am getting a strange exception being thrown.

Here is the exception which is being thrown:

"StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:\r\n{\r\n Transfer-Encoding: chunked\r\n X-SourceFiles: =?UTF-8?B?QzpcRGV2ZWxvcG1lbnRcU291cmNlQ29kZVxTVVBTZXJ2aWNlXFNVUC5TZXJ2aWNlXHNpZ25hbHJcbmVnb3RpYXRl?=\r\n Cache-Control: private\r\n Date: Wed, 11 Mar 2015 10:50:18 GMT\r\n Server: Microsoft-IIS/8.0\r\n X-AspNet-Version: 4.0.30319\r\n X-Powered-By: ASP.NET\r\n Content-Type: text/html; charset=utf-8\r\n}"

An unhandled exception of type 'System.AggregateException' occurred in SignalR Client Connection.exe

The Owin Startup file is placed within the Web Service App_Start folder, here is what it looks like:

using System;
using System.Threading.Tasks;
using Microsoft.Owin;
using Owin;
using Microsoft.AspNet.SignalR;

[assembly: OwinStartup(typeof(Service.App_Start.Startup))]

namespace Service.App_Start
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.Map("/signalr", map =>
            {
                var hubConfiguration = new HubConfiguration
                {
                    EnableDetailedErrors = true,
                    EnableJSONP = true
                };

                map.RunSignalR(hubConfiguration);
            });
        }
    }
}

Many thanks.

1
please find a better title to your question!user57508
Does your System.AggregateException have an inner exception? If so, what is it? I find that SignalR can communicate simple strings no problem, but if I try to send more complex objects sometimes I receive the aggregate exception.user8128167

1 Answers

0
votes

I am not sure the details in your case, but for me I found that I was receiving the System.AggregationException:

System.AggregateException was unhandled
  HResult=-2146233088
  Message=One or more errors occurred.
  Source=mscorlib
  StackTrace:
       at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
       at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
       at System.Threading.Tasks.Task.Wait()
       at Client.CommunicationHandler.AddMessage(String method, String args, String serverUri, String hubName) in c:\Workspace\EnvisionRealTimeRemoteOps\CodeProjectSelfHostedBroadcastServiceSignalRSample\Client\CommunicationHandler.cs:line 24
       at Client.Program.Main(String[] args) in c:\Workspace\EnvisionRealTimeRemoteOps\CodeProjectSelfHostedBroadcastServiceSignalRSample\Client\Program.cs:line 15
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.Net.Http.HttpRequestException
       HResult=-2146233088
       Message=An error occurred while sending the request.
       InnerException: System.Net.WebException
            HResult=-2146233079
            Message=Unable to connect to the remote server
            Source=System
            StackTrace:
                 at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
                 at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
            InnerException: System.Net.Sockets.SocketException
                 HResult=-2147467259
                 Message=No connection could be made because the target machine actively refused it 127.0.0.1:8083
                 Source=System
                 ErrorCode=10061
                 NativeErrorCode=10061
                 StackTrace:
                      at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
                      at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
                 InnerException: 

Until I added a call to the following:

WebApp.Start("http://localhost:8083"); // Put your desired URL in...

Please note that in my case my application is using Self-Hosted SignalR.