Hi,
IIS Version: 10.0.14393.0
OS: Windows Server 2016
Have a website with a custom http binding 8000 and under this we have ~13 different web applications. Each application uses the same pool.
In the web.config of each application folder we have the following;
<handlers>
<add name="ProcessHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath=".\run.bat"
arguments="%HTTP_PLATFORM_PORT%"
startupTimeLimit="60"
processesPerApplication="1">
<environmentVariables>
<environmentVariable name="SERVER_PORT" value="%HTTP_PLATFORM_PORT%" />
</environmentVariables>
</httpPlatform>
The reason for this is we run a python module that is called through run.bat.
What we have noticed is when requests are made concurrently to the different web applications on start up duplicate port numbers are being allocated to %HTTP_PLATFORM_PORT%. This was confirmed by watching the process path and arguments being supplied to the batch file.
The result of this is for a brief period of time there are multiple python processes running on the same port. I say brief because something detects this port duplication and kills the offending process which results in the application being restarted under a new port.
The downside of this process is our first requests are either coming back with a 502 (Bad Gateway) or a 404 (Not Found)
We can explain why this is happening as sometimes the web application does not retry hence there is no application running. The 404 can be explained because of the two modules utilising the same port. A request comes in for a specific url/module and the other module is responding.
Definitely appears to be a timing issue as if we space our requests out then the modules get allocated a different port.
Hoping somebody can shed light on this issue.
EDIT
Further to this changing from httpPlatformHandler to AspNetCoreModuleV2 seemed to resolve the issue
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath=".\run.bat"
arguments="%ASPNETCORE_PORT%"
startupTimeLimit="60"
processesPerApplication="1">
<environmentVariables>
<environmentVariable name="SERVER_PORT" value="%ASPNETCORE_PORT%" />
</environmentVariables>
</aspNetCore>
However I would like to know how the two modules select a free port and whether this is likely to occur again.
Thanks