Bug: CurlException Couldn't connect to Server when running multiple tests #99

Closed
opened 2025-12-29 14:22:28 +01:00 by adam · 2 comments
Owner

Originally created by @oscarwest on GitHub (May 8, 2018).

Seems to be the same issue as this: https://github.com/WireMock-Net/WireMock.Net/issues/44

<TargetFramework>netcoreapp2.0</TargetFramework>
<PackageReference Include="WireMock.Net" Version="1.0.3.16" />

Using

_server = FluentMockServer.Start();

Tried with/without Thread.Sleep up to 500ms

Sending in to HttpClient as BaseUrl.
_server.Urls.First();

Always works when running tests individually.
Tried making NUnit tests non-async.

        [SetUp]
        public void SetUp() {
            _server = FluentMockServer.Start();
            Thread.Sleep(100);
            var url = _server.Urls.First();

            _configuration = new ConfigurationBuilder().AddInMemoryCollection(new Dictionary<string, string>() { 
                { "BaseUrl", url }
                }).Build();

            _sut = new AdapterClass(new HttpClientWrapper(new ExceptionFactory(), new Config(_configuration, null)
        }
[TearDown]
        public void TearDown() {
            _server.Stop();
            _server.Reset();
            _server.Dispose();
            Thread.Sleep(100);
        }
Originally created by @oscarwest on GitHub (May 8, 2018). Seems to be the same issue as this: https://github.com/WireMock-Net/WireMock.Net/issues/44 ``` xml <TargetFramework>netcoreapp2.0</TargetFramework> <PackageReference Include="WireMock.Net" Version="1.0.3.16" /> ``` Using ``` c# _server = FluentMockServer.Start(); ``` Tried with/without Thread.Sleep up to 500ms Sending in to HttpClient as BaseUrl. `_server.Urls.First();` Always works when running tests individually. Tried making NUnit tests non-async. ``` c# [SetUp] public void SetUp() { _server = FluentMockServer.Start(); Thread.Sleep(100); var url = _server.Urls.First(); _configuration = new ConfigurationBuilder().AddInMemoryCollection(new Dictionary<string, string>() { { "BaseUrl", url } }).Build(); _sut = new AdapterClass(new HttpClientWrapper(new ExceptionFactory(), new Config(_configuration, null) } ``` ``` c# [TearDown] public void TearDown() { _server.Stop(); _server.Reset(); _server.Dispose(); Thread.Sleep(100); } ```
adam closed this issue 2025-12-29 14:22:28 +01:00
Author
Owner

@StefH commented on GitHub (Jun 2, 2018):

This is still and issue with the latest version?

@StefH commented on GitHub (Jun 2, 2018): This is still and issue with the latest version?
Author
Owner

@oscarwest commented on GitHub (Jun 13, 2018):

Test seems to work when updating to 1.0.3.20. Thanks!

@oscarwest commented on GitHub (Jun 13, 2018): Test seems to work when updating to 1.0.3.20. Thanks!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#99