Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SignalR Fails with more than 2 connections

I have written a fairly simple chat application in SignalR.

It seems if i connect with more than 2 tabs/browsers/devices the third will hang and never connect and eventually cause problems.

Why can I only connect with 2 users?

The third request goes through as soon as I disconnect one of the other 2.

Doesn't matter if I use the same user or different users.

I am using IIS on Windows 10, Asp.Net MVC5 with SignalR 2.2

It never calls the hub code, if I try to connect with a fourth client while that tab is open the fourth tab won't even return the view. This is the client side logging.

$.connection.hub.start().done(function () {
    //add all existing messages when we start the connection
    //chat.server.addExistingMessages();
    console.log('Now connected, connection ID=' + $.connection.hub.id);

console.log is never hit for the third connection.

$.connection.hub.start()

Is hit, and the connection and hub have values that aren't null.

  public override Task OnConnected()
    {

Is never hit on the third connection unless I terminate one of the other two. So sharing the internals of these methods/functions would only add confusion I feel.

$.connection.hub.starting(function () {
    console.log('starting')
});
$.connection.hub.received(function () {
    console.log('connection received')
});

On the third client, starting his put in the console but received isn't.

like image 582
Nathan Avatar asked Oct 30 '22 20:10

Nathan


1 Answers

I believe I was able to discover the answer to this after much hair pulling out and frustration.

Because desktop IIS only allows 10 concurrent connections and websocket connections are so dynamic I think that it was acting as 10 connections with only 2 actual connections. http://www.asp.net/signalr/overview/getting-started/supported-platforms

"full versions of IIS or Cassini should not be used, since there will be a limit of 10 simultaneous connections imposed, which will be reached very quickly since connections are transient, frequently re-established, and are not disposed immediately upon no longer being used. IIS Express should be used on client operating systems."

If that is not the case then someone please correct me!

As a work around I am going to use IIS Express, my reasoning behind not wanting to was becauase I wanted my site exposed so my co-workers could connect and sanity test. I figured out how to expose IIS to the web and run it from a command prompt so I can develop while the server is up. This is how to expose IIS Express Go to c:\Users[YourName]\Documents\IISExpress\config\applicationhost.config

Add(replacing IP address and port appropriately):

<binding protocol="http" bindingInformation="*:58938:192.168.1.42" />

To the relevant site.

Running IIS from command line

Open a command prompt.

You do not need Administrator user rights to run the commands in this walkthrough. However, you must have Administrator user rights if you want to run IIS Express on ports numbered 1024 or less. Run the following command to navigate to the IIS Express installation folder:

cd \Program Files\IIS Express 

or if you are using a 64-bit OS, run the following command: cd \Program Files (x86)\IIS Express Run the following command to view the IIS Express usage string:

iisexpress /site:site-name

and of course don't forget about port forwarding and firewall pass through.

like image 77
Nathan Avatar answered Nov 18 '22 13:11

Nathan