Closed domwvitality closed 1 month ago
172.18.0.1 is your private local ip-address?
Yeah, that's correct. Docker is used to start various services we depend on and they get assigned this address and an available port number
I understand. The logic has been changed indeed. I'll change the code in https://github.com/WireMock-Net/WireMock.Net/pull/1100
And if you want, you can test a preview version 1.5.52-ci-18499
, see
https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions
@domwvitality Did you have time to test the preview version?
@StefH Sure, will try and get that tested and confirmed today.
Hi @StefH ,
Apologies for the delay. I've just got round to testing that build and it fails for me when starting the server. I'm using the same snippet...
Service = WireMockServer.Start(new WireMockServerSettings
{
Urls = new[] { "http://172.18.0.1:8102" }
});
but when I execute I get this error...
WireMock.Exceptions.WireMockException: Service start failed with error: One or more errors occurred. (Cannot assign requested address)
---> System.AggregateException: One or more errors occurred. (Cannot assign requested address)
---> System.Net.Sockets.SocketException (99): Cannot assign requested address
at System.Net.Sockets.Socket.UpdateStatusAfterSocketErrorAndThrowException(SocketError error, String callerName)
at System.Net.Sockets.Socket.DoBind(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Bind(EndPoint localEP)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportOptions.CreateDefaultBoundListenSocket(EndPoint endpoint)
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketConnectionListener.Bind()
at Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.SocketTransportFactory.BindAsync(EndPoint endpoint, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Infrastructure.TransportManager.BindAsync(EndPoint endPoint, ConnectionDelegate connectionDelegate, EndpointConfig endpointConfig, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.<>c__DisplayClass30_0`1.<<StartAsync>g__OnBind|0>d.MoveNext()
--- End of stack trace from previous location ---
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindEndpointAsync(ListenOptions endpoint, AddressBindContext context, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.ListenOptions.BindAsync(AddressBindContext context, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.EndpointsStrategy.BindAsync(AddressBindContext context, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.AddressBinder.BindAsync(IEnumerable`1 listenOptions, AddressBindContext context, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.BindAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Server.Kestrel.Core.KestrelServerImpl.StartAsync[TContext](IHttpApplication`1 application, CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.WebHost.StartAsync(CancellationToken cancellationToken)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token, String startupMessage)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.RunAsync(IWebHost host, CancellationToken token)
--- End of inner exception stack trace ---
--- End of inner exception stack trace ---
at WireMock.Server.WireMockServer..ctor(WireMockServerSettings settings)
at WireMock.Server.WireMockServer.Start(WireMockServerSettings settings)
On my system:
Ethernet adapter vEthernet (Default Switch):
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::44c8:b60d:87e1:8437%27
IPv4 Address. . . . . . . . . . . : 172.19.80.1
Subnet Mask . . . . . . . . . . . : 255.255.240.0
Default Gateway . . . . . . . . . :
var serverOnPrivateIPAddress172_19 = WireMockServer.Start(new WireMockServerSettings
{
Urls = new[] { "https://172.19.80.1:8103" }
});
System.Console.WriteLine($"{string.Join(", ", serverOnPrivateIPAddress172_19.Urls)}");
serverOnPrivateIPAddress172_19.Stop();
This works fine.
Are you sure you that 172.18.0.1 is your local ip-address from your PC?
Hi @StefH ,
My apologies, you're right, the IP was wrong. Retested with http://172.19.0.1 and all is working as expected.
When I try and configure a my WireMockServer to start with a specific address it is overwritten when created and replaced with 'localhost'.
The code above would create a new server with a URL of 'http://localhost:8102' instead of 'http://172.18.0.1:8102'
I noticed that version 1.1.10 is the last version which would set the URL to what I provided, anything after this replaced it with 'localhost'.
Is this expected behaviour?