When SignalR made 8-10 connections at a time live chat doesn't work

社会主义新天地 提交于 2020-01-11 03:57:12

问题


I am developing live chat using SignalR. It is great library. But i coped with one problem that I cant resolve for some time. So problem in when signalR made 8-10 connections at a time live chat doesn't work any more. Maybe it is b/c i run everything on local machine?

I thought maybe I made mistake somewhere. So I found simplest chat. You can download it here. I opened it in 10 windows and it dont work anymore. Is that performance issue of signalR or programmers mistake? How can i make it work faster?

Also I found JabbR chat . And it has live demo and it works for a lot of people. They dont make anything special and it work greatly.

Can someone help with this issue?

Great thanks for any help, Dima.


回答1:


There are two problems you might have ran into:

  1. IIS/Cassini on Windows 7 has a default limit of 10 concurrent connections. Try running tests on Windows Server and see if it behaves the same.
  2. Try opening the connections in separate browser windows and/or separate browsers and/or machines, not tabs. I noticed that in 0.4 things can mess up when using tabs.



回答2:


Found how to workaround:

Rewrite connectionId, so in every tab you'd have the same sonnection id:

 public class MyConnectionFactory : IConnectionIdGenerator
    {
        public string GenerateConnectionId(IRequest request)
        {
            return MyUserManager.Instance.CurrentUserID.ToString();
        }
    }

Add to global.asax:

GlobalHost.DependencyResolver.Register(typeof(IConnectionIdGenerator), () => new MyConnectionFactory());

And I managed to open as mach tabs, as I could. And all tabs get notifications.

Hope, that helped.



来源:https://stackoverflow.com/questions/10426163/when-signalr-made-8-10-connections-at-a-time-live-chat-doesnt-work

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