Android Question Two android devices not served in the same time in IIS

hatzisn

Well-Known Member
Licensed User
Longtime User
Dear all,

I have installed IIS in a Windows 10 machine. I have developed 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. 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. 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 the service 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. Can anyone of you make anything out of all these that I have told you? Is there a way out/solution for this problem?

I also have found this on the Internet:

https://stackoverflow.com/questions...ltiple-devices-cannot-connect-the-same-server

I am not sure though it refers to IIS. I googled it and there are not any pages for "tcp kernel reuse connection" that have to do with IIS. For me it is not obvious how to take advantage of this article in stackoverflow. Is it to anyone of you?


Thanks in advance
 

hatzisn

Well-Known Member
Licensed User
Longtime User
Got something here:

In this article in stackoverflow it is stated:
https://stackoverflow.com/questions...serve-multiple-requests-from-a-single-process


This is primarily due to ASP.net's session state variable and the fact that only one request at a time may have R/W access to a particular session (as determined by the SessionID cookie).

Any additional requests requiring any form of session access (since Read/Write is the default) will be blocked until the previous request has been completed.

Based on the following links:

http://johnculviner.com/asp-net-concurrent-ajax-requests-and-session-state-blocking/
https://msdn.microsoft.com/en-us/library/ms178581.aspx?f=255&MSPPError=-2147217396


I suppose this is not my case since the requests are done from 2 different phones...




And in this article in MSDN it is stated:
https://msdn.microsoft.com/en-us/library/ms178581.aspx


Concurrent Requests and Session State

Access to ASP.NET session state is exclusive per session, which means that if two different users make concurrent requests, access to each separate session is granted concurrently. However, if two concurrent requests are made for the same session (by using the same SessionID value), the first request gets exclusive access to the session information. The second request executes only after the first request is finished. (The second session can also get access if the exclusive lock on the information is freed because the first request exceeds the lock time-out.) If the EnableSessionState value in the @ Page directive is set to ReadOnly, a request for the read-only session information does not result in an exclusive lock on the session data. However, read-only requests for session data might still have to wait for a lock set by a read-write request for session data to clear.



And a proposed solution that did not work for me so far (in Global.asax):

Sollution:

B4X:
    Protected Sub Application_BeginRequest(sender As Object, e As System.EventArgs)
        If Context.Request.Path.EndsWith("xxx.ccc") Then
            Context.SetSessionStateBehavior(SessionStateBehavior.ReadOnly)
        End If
    End Sub


So I wonder why does it have the same session for two different phones (does it recognize the environment? --> same app/package with same okhttp library and same IP?).

Edit -
Tested my code in an on-line server and it works with two concurrent requests from my IP. It definetely has to do with server settings...
 
Last edited:
Upvote 0
Top