mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
WireMock.Net fails during startup with a System.Net.Sockets.SocketException #324
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @SimonA84 on GitHub (Dec 21, 2020).
I use the nuget package of WireMock.Net for unit tests with xunit. I want to use a port like 19999 to be outside of the range of well known ports.
How to Reproduce it:
var settings = new WireMockServerSettings{Port = 19999}; var server = WireMockServer _server = WireMockServer.Start(settings);What happens:
The server throws in the line with WireMockServer.Start an Wiremock.Exceptions.WireMockException with "Service start failed with error: At least one error occoured"
The inner exceptions are
(Sorry if you don't have the exact same message. My system is set to german)
What I tried:
What I want:
I want to understand why this happens and how to solve and prevent this problem.
@StefH commented on GitHub (Dec 21, 2020):
Add some "endpoints"--> you mean add some mappings ?@StefH commented on GitHub (Dec 21, 2020):
-Are you able to start the example console apps in this solution ?
@SimonA84 commented on GitHub (Dec 21, 2020):
Yes. I mean with endpoints some mappings. The extended URL is by my collegues an endpoint.
I'm using a Win10 x64 Enterprise.
I don't start WireMock.net as a dedicated app. I start it in the tests that I'm running. Like in the following snippet.
As I told at the beginning. I use it in xunit tests.
@StefH commented on GitHub (Dec 21, 2020):
Hello @SimonA84,
It is advised to use random ports in unit tests.
https://github.com/WireMock-Net/WireMock.Net/wiki/Using-WireMock-in-UnitTests
@SimonA84 commented on GitHub (Dec 21, 2020):
I changed it to use different ports. It works, but I prefere using a fix port. An external server does not change the port
@StefH commented on GitHub (Dec 21, 2020):
In that case, a possible solution would be to start the server once in the constructor/setup from the unit-test.
Can you try that?
@SimonA84 commented on GitHub (Dec 22, 2020):
I got a working solution with one single port and it "recreates" the server in the constructor for each test as before (with stoping it afterwards).
But what I don't understand is why this port works and the other one has the permission problem
When I take a look at the list of standardized ports in wikipedia (I know the list is not well maintained), then I see that both ports (working: 5001 and not working: 9999) are used by some things which I don't have on my system. Netstat tells me that both ports aren't in use when I don't run my tests with WireMock.
@SimonA84 commented on GitHub (Dec 28, 2020):
Thanks for your support.