Actually I don't even talk about concurrent connections (I'm aware of this limitation), Here is the flow however.
1. Pressing on submit button calls an aspx page / mvc controller via ajax.
2. Server code is invoking a method on the hub (sample code I've attached above)
3. CLient hub method is invoked and written to the browser console with a counter like (client function called 1,2 ...)
4, Then pressing on the submit button again (only after it returned from the server, so its one after the other)
5. After 8 connections it hangs and I have to restart IIS
Just when I change the server code to work with static variables and wait for the connection to start only if its disconnected then it works ok.
This is not the way I'm working with web reuqest or even db connections. I'm not saving state on the web
In addition, with this implementation I'm working only with one connection where I could work with much more.
A single connection is much more efficient. Windows 7 on IIS has the 10 concurrent connection limit and you're likely hitting that. You need to either close the connection each time or just stop your single ton on app shutdown.
erans
0 Points
3 Posts
Cannot work per call with signalr connections
Feb 05, 2013 05:32 AM|LINK
when created the connection and the hub per request (old code) :
connection = new HubConnection(signalrUrl); connection.Credentials = CredentialCache.DefaultNetworkCredentials; notificationHub = connection.CreateHubProxy("notificationHub"); connection.Start().Wait(); hub.Invoke("sendNotification", connectionId, hashKey); it hangs after 8 connectionsif (conn.State == ConnectionState.Disconnected) { lock (conn) { if (conn.State == ConnectionState.Disconnected) { conn.Start().Wait(); } } } hub.Invoke("sendNotification", connectionId, hashKey).ContinueWith(task => { if (task.IsFaulted && task.Exception != null) { // log error } });davidfowl
Contributor
2676 Points
605 Posts
Microsoft
Re: Cannot work per call with signalr connections
Feb 05, 2013 05:57 PM|LINK
By default in .NET the maximum concurrent connections you can have open to the same domain is 2 on the client and 10 in ASP.NET. To increase this limit you can increase this property http://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.defaultconnectionlimit(v=vs.110).aspx.
Are you using full IIS on windows 7 or 8? There's also a concurrent connection limit of 10 there.
When you say it hangs after 8 connections, what do you mean? Do you create 8 HubConnections? or did you invoke send notification 8 times?
What kind of application are you running in? A web/windows/console application?
I'm not sure why it wouldn't hang if you wrote it in a non blocking way but answering some of those questions might clear it up.
Senior SDE, ASP.NET Team, Microsoft
erans
0 Points
3 Posts
Re: Cannot work per call with signalr connections
Feb 05, 2013 08:00 PM|LINK
Actually I don't even talk about concurrent connections (I'm aware of this limitation), Here is the flow however.
1. Pressing on submit button calls an aspx page / mvc controller via ajax.
2. Server code is invoking a method on the hub (sample code I've attached above)
3. CLient hub method is invoked and written to the browser console with a counter like (client function called 1,2 ...)
4, Then pressing on the submit button again (only after it returned from the server, so its one after the other)
5. After 8 connections it hangs and I have to restart IIS
Just when I change the server code to work with static variables and wait for the connection to start only if its disconnected then it works ok.
This is not the way I'm working with web reuqest or even db connections. I'm not saving state on the web
In addition, with this implementation I'm working only with one connection where I could work with much more.
Can you elaborate on that ?
Eran
davidfowl
Contributor
2676 Points
605 Posts
Microsoft
Re: Cannot work per call with signalr connections
Feb 05, 2013 09:16 PM|LINK
But you're leaving connections open if you aren't stopping them. You also didn't answer all of my questions.
Senior SDE, ASP.NET Team, Microsoft
erans
0 Points
3 Posts
Re: Cannot work per call with signalr connections
Feb 06, 2013 05:29 AM|LINK
Would you recommend closing the connection everytime or static approach is a better one ?
davidfowl
Contributor
2676 Points
605 Posts
Microsoft
Re: Cannot work per call with signalr connections
Feb 06, 2013 05:33 AM|LINK
A single connection is much more efficient. Windows 7 on IIS has the 10 concurrent connection limit and you're likely hitting that. You need to either close the connection each time or just stop your single ton on app shutdown.
Senior SDE, ASP.NET Team, Microsoft