-
Notifications
You must be signed in to change notification settings - Fork 308
SelfHostDeployer still produces AddressInUseException #1296
Comments
@anurse what's the work proposed here? |
Depends on if this is still a persistent problem on the CI. In order to figure out why it's still happening, we'd either need more logging or to make our tests way more defensive about addresses being in use. |
It is still happening on the CI. When you say more logging you mean in the SelfHostDeployer right? |
Yes |
@JunTaoLuo Whenever you have some free time, can you take a look? |
Here's a non-exhaustive (but reasonably through) list of the builds that were failed by this. As you can see it happens about once or more per-day. |
Any movement on this? It fails 2+ times a day. |
I'll make some time to take a look at it this week. |
SelfHostDeployer currently works as follows:
This design was based on the assumption that the OS will not reuse the assigned port between step 3 and step 5. This assumption is usually true, but sometimes the OS does reuse the port, which causes one of the external processes to fail to bind. See repro at https://github.com/mikeharder/GetNextPort, which fails after a few seconds on my machine. The most reliable workaround is to always start the external process on port Hosting/src/Microsoft.AspNetCore.Server.IntegrationTesting/Deployers/SelfHostDeployer.cs Line 135 in 311a92d
But it also has logic to handle apps which don't print the assigned port: Hosting/src/Microsoft.AspNetCore.Server.IntegrationTesting/Deployers/SelfHostDeployer.cs Line 176 in 311a92d
It appears the only apps which don't print the assigned port are tests specifically for this logic: So, I think the most reliable fix:
SignalR also uses But I believe it can be changed to use port Kestrel also uses This usage needs to stay, since it's specifically testing that Kestrel can bind to a non-zero port. There's still a race condition if AddressRegistrationTests is running in parallel with another process binding to port 0, but even if this happens, the frequency of this failure will be significantly reduced (likely to 0). Will send a PR tomorrow. |
Keep in mind that HttpSys also uses the SelfHost deployer in ServerTests and MusicStore and doesn't support binding to port 0. I don't see it calling GetNextPort directly, but I don't recall how it's test port is allocated otherwise. |
This particular presentation of this error is new to me. |
@ryanbrandenburg: What is different about http://aspnetci/viewLog.html?buildId=432346&buildTypeId=XPlat_Windows_Win8_Universe? It looks like the typical error message:
|
What was different to me was that it was throwing CSC 255 at the top of the exception and was showing a stack-trace out of CompilerServices. |
Updating the milestone as we're closing on preview2. If this is ready to checkin to release/2.1 branch, though, I think we should still be able to. |
@mikeharder Do you plan to do any work on this in RC1? |
@muratg: Yes, I will work on this tomorrow and Friday. |
* Should significantly reduce flaky test failures due to AddressInUse exceptions * Addresses #1296
* Should significantly reduce flaky test failures due to AddressInUse exceptions * Addresses #1296
* Should significantly reduce flaky test failures due to AddressInUse exceptions * Addresses #1296
We run into this kind of thing still. I believe previously @anurse added extra logging to this scenario.
The text was updated successfully, but these errors were encountered: