SignalR .NET Client throw error during connection start

211 Views Asked by At

I face the next problem. I try to connect to SignalR server. I create HubConnection instance and the start connection. That is successfully. But when I create proxy hub for that connection I get exception. SignalR version 2.2.0 Code example:

hubConnection = new HubConnection(inputDataContract.rootUrl + inputDataContract.defaultServicePath);
hubConnection.TraceLevel = TraceLevels.All;
hubConnection.TraceWriter = Console.Out;
hubConnection.Start().ContinueWith(task => {
            if (task.IsFaulted)
            {
                Console.WriteLine("There was an error opening the connection:{0}",
                                  task.Exception.GetBaseException());
            }
            else
            {
                Console.WriteLine("Connected");
            }

        }).Wait();

hubConnection.Stop();

That above code is executed successfully.

Log of connection

But next piece of code leads to error

hubConnection = new HubConnection(inputDataContract.rootUrl + inputDataContract.defaultServicePath);
            hubConnection.TraceLevel = TraceLevels.All;
            hubConnection.TraceWriter = Console.Out;

            hubProxy = hubConnection.CreateHubProxy("Configurator");

            hubProxy.On<EventArgs>("valueChanged", res => onValueChanged(res));
            hubProxy.On<EventArgs>("configurationStateChanged", res => onConfigurationStateChanged(res));
            hubProxy.On<EventArgs>("componentModifierChanged", res => onComponentModifierChanged(res));
            hubProxy.On<EventArgs>("attributeFeasibility", res => onAttributeFeasibility(res));
            hubProxy.On<EventArgs>("attributeModifierChanged", res => onAttributeModifierChanged(res));
            hubProxy.On<EventArgs>("calculationSummary", res => onCalculationSummary(res));
            hubProxy.On<EventArgs>("configurationError", res => onConfigurationError(res));
            hubProxy.On<EventArgs>("unhandledTaskException", res => onUnhandledTaskException(res));


            hubConnection.Start().ContinueWith(task => {
                if (task.IsFaulted)
                {
                    Console.WriteLine("There was an error opening the connection:{0}",
                                      task.Exception.GetBaseException());
                }
                else
                {
                    Console.WriteLine("Connected");
                }

            }).Wait();

            hubConnection.Stop();

Error msg

I will be very appreciate for any help.

0

There are 0 best solutions below