WireMock server fails to respond when run from VS test process #236

Closed
opened 2025-12-29 15:18:54 +01:00 by adam · 1 comment
Owner

Originally created by @peitschie on GitHub (Dec 18, 2019).

TL;DR: WireMock for net641 (i.e., AspNetCore) hangs when executed from some Visual Studio test runners. The solution is to upgrade to Microsoft.AspNetCore v2.1.7. This can be done simply by referencing the Microsoft.AspNetCore v2.1.7 nuget package directly in the same library/console app that is referencing the WireMock nuget package.

This isn't a WireMock bug per se, but I wanted to log it here just in case others hit this problem.

The long version:

I'm using SpecFlow with the SpecFlow extension in Visual Studio 2017 on a .NET 4.6.1 project. I found that running WireMock with Kestrel from within this the Visual Studio test runner (via Test Explorer) seems to hang in an odd way, in that HTTP calls made to the mock never complete.

I used ProcessExplorer to verify that testhost.x86.exe had successfully opened the port, but any calls made to it (e.g., from a browser, from Postman) would have the connection hang at the "ESTABLISHED" phase, with no response ever being returned.

I verified that the exact same code run directly from a net461 console app did work as expected, and did not exhibit this hang.

I downloaded and compiled WireMock directly, and was able to verify that the issue was Kestrel itself not firing any callbacks. I could see Kestrel starting up correctly, but no call ever seemed to get back out. I hacked up the source and verified this issue did no occur with the Owin-based host... only the Kestrel / AspNetCore host.

Eventually, I gave up trying to figure out what was wrong (nothing obvious in sight... perhaps something related to the multiple AppDomains & shared app domains the test runner uses?), and simply upgraded AspNetCore to the most recent 2.1.X series. This fixed the issue.

Perhaps some minor tweaks that might be made:

  1. I might suggest upgrading the Microsoft.AspNetCore version in the library to a later version... (though, my issue here is obviously not widespread, as I could find no other bug report with similar behaviour anyway)
  2. Make the host configurable, so that Owin/AspNetCore host can be swapped out without needing to recompile the library from scratch

But... these are not really important to me, as I have things working now by manually setting the AspNetCore package in the test assembly to a recent version 😅 .

Originally created by @peitschie on GitHub (Dec 18, 2019). TL;DR: WireMock for net641 (i.e., AspNetCore) hangs when executed from some Visual Studio test runners. The solution is to upgrade to Microsoft.AspNetCore v2.1.7. This can be done simply by referencing the Microsoft.AspNetCore v2.1.7 nuget package directly in the same library/console app that is referencing the WireMock nuget package. This isn't a WireMock bug per se, but I wanted to log it here just in case others hit this problem. The long version: I'm using SpecFlow with the SpecFlow extension in Visual Studio 2017 on a .NET 4.6.1 project. I found that running WireMock with Kestrel from within this the Visual Studio test runner (via Test Explorer) seems to hang in an odd way, in that HTTP calls made to the mock never complete. I used ProcessExplorer to verify that `testhost.x86.exe` had successfully opened the port, but any calls made to it (e.g., from a browser, from Postman) would have the connection hang at the "ESTABLISHED" phase, with no response ever being returned. I verified that the exact same code run directly from a net461 console app did work as expected, and did not exhibit this hang. I downloaded and compiled WireMock directly, and was able to verify that the issue was Kestrel itself not firing any callbacks. I could see Kestrel starting up correctly, but no call ever seemed to get back out. I hacked up the source and verified this issue did no occur with the Owin-based host... only the Kestrel / AspNetCore host. Eventually, I gave up trying to figure out what was wrong (nothing obvious in sight... perhaps something related to the multiple AppDomains & shared app domains the test runner uses?), and simply upgraded AspNetCore to the most recent 2.1.X series. This fixed the issue. Perhaps some minor tweaks that might be made: 1. I might suggest upgrading the Microsoft.AspNetCore version in the library to a later version... (though, my issue here is obviously not widespread, as I could find no other bug report with similar behaviour anyway) 2. Make the host configurable, so that Owin/AspNetCore host can be swapped out without needing to recompile the library from scratch But... these are not really important to me, as I have things working now by manually setting the AspNetCore package in the test assembly to a recent version 😅 .
adam added the question label 2025-12-29 15:18:54 +01:00
adam closed this issue 2025-12-29 15:18:54 +01:00
Author
Owner

@StefH commented on GitHub (Dec 18, 2019):

I'll upgrade NuGet in PR https://github.com/WireMock-Net/WireMock.Net/pull/363

@StefH commented on GitHub (Dec 18, 2019): I'll upgrade NuGet in PR https://github.com/WireMock-Net/WireMock.Net/pull/363
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#236