SignalR Hub's Groups dont work with long polling

杀马特。学长 韩版系。学妹 提交于 2019-12-11 13:32:59

问题


I have a Web App(.NET 4.0 ASP.NET MVC3) which uses SignalR(1.0.0 alpha 2) with Hubs and Persistent Connections.

With the Hubs I use groups to send push notifications to some clients.

The problem is that when the server is accessed remotely it defaults to long pooling and only the persistent connections work. With hubs the event happens on the server but my callback is not called at the client. It works locally, though it uses SSE.

What I found is that the combination of Grouping the clients and the long pooling transport is causing the problem. I will try to debug SignalR as long as I get VS2012.

To prove this I just got this chat example modified so a hard-coded group was used and long pooling was forced - it does not work, neither on my machine (IISExpress) nor on a server (IIS 7.5). The chat works as long as you use a different transport OR do

context.Clients.All.addMessage(message);

instead of

context.Clients.Group(groupName).addMessage(message);

Here is a sample project.

Is that a bug in SignalR or I'm missing something?

Any ideas why on my deployment server SignalR would fall back to long polling on port 80 but use SSE if my site is configured on a different port?


回答1:


You need to enable Auto-Rejoining groups.

Stick this in your startup code:

GlobalHost.HubPipeline.EnableAutoRejoiningGroups();



来源:https://stackoverflow.com/questions/13934676/signalr-hubs-groups-dont-work-with-long-polling

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!