SignalR组.添加超时失败 [英] SignalR Groups.Add times out and fails

查看:51
本文介绍了SignalR组.添加超时失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用SignalR 2.2将成员添加到组中.每一次,我都达到30秒超时并得到"System.Threading.Tasks.TaskCanceledException:任务已取消."错误.

I'm trying to add a member to a Group using SignalR 2.2. Every single time, I hit a 30 second timeout and get a "System.Threading.Tasks.TaskCanceledException: A task was canceled." error.

从我编写的GroupSubscriptionController中,我打电话给:

From a GroupSubscriptionController that I've written, I'm calling:

 var hubContext = GlobalHost.ConnectionManager.GetHubContext<ProjectHub>();
 await hubContext.Groups.Add(connectionId, groupName);

我发现了这个问题,人们经常会遇到此问题,但这确实发生了每次都对我我正在一个VS2015启动的本地主机端口上运行后端(ASP.NET 4.5),而在另一个VS 2015启动的本地主机端口上运行前端(AngularJS SPA).

I've found this issue where people are periodically encountering this, but it happens to me every single time. I'm running the backend (ASP.NET 4.5) on one VS2015 launched localhost port, and the frontend (AngularJS SPA) on another VS 2015 launched localhost port.

我已经使SignalR工作到将消息广播到每个连接的客户端的地步.似乎很容易.现在,添加网上论坛"部分(这样人们就只能从服务器收到选择的消息了)让我脱颖而出...

I had gotten SignalR working to the point where messages were being broadcast to every connected client. It seemed so easy. Now, adding in the Groups part (so that people only get select messages from the server) has me pulling my hair out...

推荐答案

由于在已连接客户端的SignalR注册表中找不到connectionId,因此可能引发任务取消错误.

That task cancellation error could be being thrown because the connectionId can't be found in the SignalR registry of connected clients.

您如何获得此connectionId?您有多个服务器/端口在运行-是否有可能使电线交叉?

How are you getting this connectionId? You have multiple servers/ports going - is it possible that you're getting your wires crossed?

这篇关于SignalR组.添加超时失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆