Webforms site with Web Service hosted in local IIS does not serve two Android devices at the same time - Session Lock RRS feed

  • Question

  • User-460338909 posted

    Dear all,

    I have installed IIS in a Windows 10 machine. I have developed a webforms site with a web service (.asmx) which is served in the IIS and runs in a class a long time consuming procedure. I have set up port forwarding from my rooter to the Windows 10 machine in the port the site is served. What I discovered is that if I try to hit from 2 Android phones in the same time (connected to the same router with WiFi as the server - server connected with LAN) the site in the IIS using the outside IP (router's IP in the internet), the first phone is served perfectly and the second delays big time (setting the session time out to 5 minutes in Android devices). I made sure that there are no conflicts in the local network (all devices have different static IPs) but the problem persists. If on the other hand I disconnect one of the mobile phones from the wifi and hit it with 4G from this phone, both phones are served correctly at the same time (so it is not a router forwarding issue). I searched a lot in the internet but I cannot find an answer. I created a page to display the IP of the client. When I hit this page from each phone using the outside IP again I see as it is logical the outside IP. If I change the order of the phones and hit it again with wifi from both, the same thing happens (first ok - second big time delay). I have set the IIS to serve at least 30 clients from the same IP but I had no luck.

    Searching the Internet I discovered (there are huge chances that I may be wrong) that this might have to do with the default behavior of DotNet framework which locks the session to the first in first served device:




    I suppose that my IIS assumes that the attempt to hit the web service from the second device is another attempt by the same device. I also suppose that it assumes the device to be the same device since it is the same application with the same internal environment hitting the web service and it can't tell that they are two different devices. I tried to reproduce this error and check if I am right by hitting the IP reporting page in IIS from two different tabs of the Mozzila Developer edition browser but it works ok (so I am not sure if it is a session issue). I also found a report that the issue is present only in android devices but it was not clear enough if the server was IIS... The solution mentioned was "incorrect flag on the tcp kernel settings - Reuse connection". Does it tell anything to anyone of you?

    If the session lock is indeed the problem is there a solution to make IIS distinguish that there are two devices indeed? Is there a setting in IIS that would change this default behavior of DotNet?

    I am sure there is a solution (if indeed the issue is session lock) because I uploaded my code to an on-line server and it works perfect when hitting it from two Android devices. So either it is not a session lock issue or there is a setting that it changes this behavior of DotNet in IIS... Is anyone aware of such a setting?

    Thanks in advance

    Tuesday, November 13, 2018 7:49 AM

All replies

  • User-1492487179 posted

    hello hatzisn,

    Thanks for your posting!

    Generally the reason of session lock depends on specify scenario. For example, your requests locked by each other on one method, the backend services is too slow to response for your web application  ect..

     On your scenario, your application used the long time running procedure, if your application need read or write the sessions content, you should be occurred this issue.  It is by design for the session mode . Meanwhile, you can set the enableSessionState (https://docs.microsoft.com/en-us/previous-versions/dotnet/netframework-3.0/950xf363(v=vs.85) )  value on the page if your application didn't write session value.

    About your description, it is difficult to decide that this issue is relation to the  session locks, may be it is the network issue. So I suggest that you could use debugdiag or procdump to catch the slow performance dump, and then analyze it with Windbg or Debugdiag. '

    Debugdiag: set the response time to collect the dumps: 


    Procdump: when the request was pending, you can run procdump command to collect dumps:


    Windbg Analyze:


    Tuesday, November 20, 2018 8:28 AM
  • User1120430333 posted

    The accessing of the Web server and the Web application are running on separate threads for each client, since a Web server is a multiple user and multi threaded solution with each client running on its own thread and in its own session.

    Maybe somewhere in the code execution a singleton pattern is being used.

    Maybe you have a table lock condition  in the database.

    I think that you have some kind of resource lock/block condition that is happening in a concurrent usage situation with the application  that has nothing to do with IIS or the network.

    Tuesday, November 20, 2018 9:24 AM