locked
System.AggregateException is thrown when I try to make a SignalR hubConnection Please help RRS feed

  • Question

  • User1028731656 posted

    Please help me I keep getting a System.AggregateException when I try to make a hubConnection. I have gone through many tutorials and downloaded example codes and nothing seems to work. I have also tried searching online for ways to configure my computer but it gets rather confusing too quickly. Any suggestion will be welcome. The server code is below;

    namespace ChatServer
    {
    class Program
    {
    static void Main(string[] args)
    {
    string url = "http://localhost:8080";
    using (WebApp.Start<Startup>(url))
    {
    Console.WriteLine("Server running on {0}", url);
    Console.ReadLine();
    }
    }
    }
    class Startup
    {
    public void Configuration(IAppBuilder app)
    {
    app.UseCors(CorsOptions.AllowAll);
    app.MapSignalR();
    }
    }
    }
    namespace SignalRServer
    {
        [HubName("ChatHub")]
        class ChatHub : Hub
        {
            public void sendToSpecific(string name, string message)
            {
                // Call the broadcastMessage method to update clients.
                Clients.All.broadcast_message(name, message);
            }
        }
    
    }

    and here is the code for the windows form client;

    namespace ChatClient
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    HubConnection hubConnection = new HubConnection("http://localhost:8080/");
    IHubProxy hubProxy = hubConnection.CreateHubProxy("ChatHub");
    hubProxy.On<string>("newMessageReceived", (message) => { });

    try
    {
    hubConnection.Start().Wait();
    }
    catch(AggregateException e)
    {
    //MessageBox.Show(e.ToString());
    listView1.Items.Add(e.ToString());
    }
    }
    }
    }

    I printed the error and here it is;

    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 SignalRClient.ChatForm.make_hub_connection() in c:\Users\eugene\Documents\Visual Studio 2013\Projects\MyFirstSignalRApp\SignalRClient\ChatForm.cs:line 30
           at SignalRClient.ChatForm..ctor() in c:\Users\eugene\Documents\Visual Studio 2013\Projects\MyFirstSignalRApp\SignalRClient\ChatForm.cs:line 20
           at SignalRClient.Program.Main() in c:\Users\eugene\Documents\Visual Studio 2013\Projects\MyFirstSignalRApp\SignalRClient\Program.cs:line 19
           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:8080
                     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:





    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 ChatClient.Form1..ctor() in c:\Users\eugene\Documents\Visual Studio 2013\Projects\ChattingApplication\ChatClient\Form1.cs:line 23 at ChatClient.Program.Main() in c:\Users\eugene\Documents\Visual Studio 2013\Projects\ChattingApplication\ChatClient\Program.cs:line 19 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: Microsoft.AspNet.SignalR.Client.HttpClientException HResult=-2146233088 Message=StatusCode: 500, ReasonPhrase: 'Internal Server Error', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { Date: Wed, 21 May 2014 16:01:32 GMT Server: Microsoft-HTTPAPI/2.0 Content-Length: 0 } Source=Microsoft.AspNet.SignalR.Client StackTrace: at Microsoft.AspNet.SignalR.Client.Http.DefaultHttpClient.<>c__DisplayClass2.<Get>b__1(HttpResponseMessage responseMessage) at Microsoft.AspNet.SignalR.TaskAsyncHelper.<>c__DisplayClass19`2.<Then>b__17(Task`1 t) at Microsoft.AspNet.SignalR.TaskAsyncHelper.TaskRunners`2.<>c__DisplayClass3a.<RunTask>b__39(Task`1 t) InnerException:

    Wednesday, May 21, 2014 12:49 PM

All replies

  • User1066278571 posted

    Do you have the access rights to access this? Seems like a firewall is blocking access or Web sockets is not activated on the IIS. What version of IIS do you use, Windows Version? 

    greetings Damien

    Message=No connection could be made because the target machine actively refused it 127.0.0.1:8080
    Sunday, May 25, 2014 4:32 PM
  • User1028731656 posted

    I've managed to figure out what I was doing wrong. Thanks

    Sunday, May 25, 2014 7:44 PM
  • User-518521477 posted

    Care to tell the rest of us?

    Friday, June 6, 2014 6:49 PM
  • User-1744871499 posted

    Hello Please help me , i am getting same error :( 

    Monday, January 12, 2015 9:45 AM
  • User-1744871499 posted

    hello terminatorar , 

    how did you fix that problem ?? Can you help me please.. 

    i am getting the same error but my server application is running on IIS live. and my client side application is in C# console. when i try connect console application with live server asp.net SignalR application then i getting the same error which you have already mention .. 

    Monday, January 12, 2015 9:47 AM
  • User-1843363067 posted

    <g class="gr_ gr_52 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation only-ins replaceWithoutSep" id="52" data-gr-id="52">Hello</g> I recently ha <g class="gr_ gr_12 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="12" data-gr-id="12">dthis</g> error and it was because the classes weren't public.

    Hope this helps.

    Tuesday, March 6, 2018 12:45 PM