pact-foundation / pact-net

.NET version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://pact.io
MIT License
848 stars 234 forks source link

Error Starting Messaging Provider #519

Open adamrodger opened 2 months ago

adamrodger commented 2 months ago

Version information:

Describe the bug We're seeing intermittent issues, both locally and in CI, on Windows whereby the messaging provider fails to start, with the error:

PactNet.Exceptions.PactFailureException : Unable to start the internal messaging server
---- System.Net.HttpListenerException : The process cannot access the file because it is being used by another process
  Stack Trace:
     at PactNet.Verifier.Messaging.MessagingProvider.Start(JsonSerializerOptions settings) in /_/src/PactNet/Verifier/Messaging/MessagingProvider.cs:line 85
   at PactNet.Tests.Verifier.Messaging.MessagingProviderTests..ctor(ITestOutputHelper output) in D:\a\pact-net\pact-net\tests\PactNet.Tests\Verifier\Messaging\MessagingProviderTests.cs:line 45
----- Inner Stack Trace -----
   at System.Net.HttpListener.AddAllPrefixes()
   at System.Net.HttpListener.Start()
   at PactNet.Verifier.Messaging.MessagingProvider.Start(JsonSerializerOptions settings) in /_/src/PactNet/Verifier/Messaging/MessagingProvider.cs:line 75

Steps To Reproduce Intermittently happens when running messaging tests

Expected behavior The messaging server finds a free port and starts successfully

Additional context Doesn't seem to happen on non-Windows systems