Ошибка при запуске клиента SignalR .NET при запуске соединения - PullRequest
0 голосов
/ 31 августа 2018

Я сталкиваюсь со следующей проблемой. Я пытаюсь подключиться к серверу SignalR. Я создаю экземпляр HubConnection и начальное соединение. Это успешно. Но когда я создаю прокси-концентратор для этого соединения, я получаю исключение. SignalR версия 2.2.0 Пример кода:

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();

Указанный выше код успешно выполнен.

Журнал подключения

Но следующий фрагмент кода приводит к ошибке

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();

Ошибка сообщения

Буду очень признателен за любую помощь.

...