Server not starting up with 1.0.15 code #174

Closed
opened 2025-12-29 14:24:23 +01:00 by adam · 6 comments
Owner

Originally created by @megha222 on GitHub (May 16, 2019).

Below code gets stuck on the console print.

server = FluentMockServer.StartWithAdminInterface(7000);    
server.Given(Request.Create().UsingGet().WithPath("/foo")).RespondWith(Response.Create().WithStatusCode(202).WithBody(@"ok"));
            var task = Task.WhenAll(new HttpClient().GetStringAsync("http://localhost:7000" + "/foo"));
Console.WriteLine(task.Result[0])`

Meanwhile we also see a exception in output
`Exception thrown: 'System.IO.FileNotFoundException' in Microsoft.AspNetCore.Server.Kestrel.Core.dll
Exception thrown: 'System.ObjectDisposedException' in System.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.dll

We are in a build environment where we cannot use our own nuget package manager so we have 2.2.0 version of the Kestrel dependencies which are higher than the one 1.0.15 wiremock expects so we were hoping things would work. Can you let us know how to trap the error that is happening in server start?

Originally created by @megha222 on GitHub (May 16, 2019). Below code gets stuck on the console print. ``` c# server = FluentMockServer.StartWithAdminInterface(7000); server.Given(Request.Create().UsingGet().WithPath("/foo")).RespondWith(Response.Create().WithStatusCode(202).WithBody(@"ok")); var task = Task.WhenAll(new HttpClient().GetStringAsync("http://localhost:7000" + "/foo")); Console.WriteLine(task.Result[0])` Meanwhile we also see a exception in output `Exception thrown: 'System.IO.FileNotFoundException' in Microsoft.AspNetCore.Server.Kestrel.Core.dll Exception thrown: 'System.ObjectDisposedException' in System.dll Exception thrown: 'System.Net.Sockets.SocketException' in System.dll ``` We are in a build environment where we cannot use our own nuget package manager so we have 2.2.0 version of the Kestrel dependencies which are higher than the one 1.0.15 wiremock expects so we were hoping things would work. Can you let us know how to trap the error that is happening in server start?
adam added the invalidquestion labels 2025-12-29 14:24:23 +01:00
adam closed this issue 2025-12-29 14:24:23 +01:00
Author
Owner

@StefH commented on GitHub (May 16, 2019):

You have Microsoft.AspNetCore version 2.2.0 ?

@StefH commented on GitHub (May 16, 2019): You have **Microsoft.AspNetCore** version 2.2.0 ?
Author
Owner

@StefH commented on GitHub (May 16, 2019):

I did a quick test with Microsoft.AspNetCore version 2.2.0 (added to https://github.com/WireMock-Net/WireMock.Net/tree/master/examples/WireMock.Net.Console.NETCoreApp2) and it works ok.

@StefH commented on GitHub (May 16, 2019): I did a quick test with Microsoft.AspNetCore version 2.2.0 (added to https://github.com/WireMock-Net/WireMock.Net/tree/master/examples/WireMock.Net.Console.NETCoreApp2) and it works ok.
Author
Owner

@ElSiipo commented on GitHub (May 21, 2019):

I hope it's fine that I piggyback on this thread.

I have a issue with getting the server to start (on .NET Framework 4.7.2), which started to occur while migrating from EntityFramework to EntityFramework Core.
I'm constantly getting the following exception when trying to run httpClient.PostAsync(...)

WebException: The underlying connection was closed: The connection was closed unexpectedly.

We had no problems with this before starting to migrating to EF Core.
When inspecting the server object, IsStarted is true.

I get a slight feeling that startTask from var startTask = _httpServer.StartAsync() is not started, but I can't really say for sure.

Example code
var testserver = FluentMockServer.Start(7000); testserver.Given(Request.Create().UsingGet().WithPath("/foo")).RespondWith(MockResponse.Create().WithStatusCode(202).WithBody(@"ok")); var task = Task.WhenAll(new HttpClient().GetStringAsync("http://localhost:7000" + "/foo"));

this results in

HttpRequestException: An error occurred while sending the request.

and

WebException: The underlying connection was closed: The connection was closed unexpectedly.

@ElSiipo commented on GitHub (May 21, 2019): I hope it's fine that I piggyback on this thread. I have a issue with getting the server to start (on _.NET Framework 4.7.2_), which started to occur while migrating from EntityFramework to EntityFramework Core. I'm constantly getting the following exception when trying to run `httpClient.PostAsync(...)` >WebException: The underlying connection was closed: The connection was closed unexpectedly. We had no problems with this before starting to migrating to EF Core. When inspecting the server object, `IsStarted` is `true`. I get a slight feeling that startTask from `var startTask = _httpServer.StartAsync()` is not started, but I can't really say for sure. Example code `var testserver = FluentMockServer.Start(7000); testserver.Given(Request.Create().UsingGet().WithPath("/foo")).RespondWith(MockResponse.Create().WithStatusCode(202).WithBody(@"ok")); var task = Task.WhenAll(new HttpClient().GetStringAsync("http://localhost:7000" + "/foo"));` this results in >HttpRequestException: An error occurred while sending the request. and >WebException: The underlying connection was closed: The connection was closed unexpectedly.
Author
Owner

@StefH commented on GitHub (May 21, 2019):

@ElSiipo Can you provide a example project ?

@StefH commented on GitHub (May 21, 2019): @ElSiipo Can you provide a example project ?
Author
Owner

@megha222 commented on GitHub (Jun 11, 2019):

I did a quick test with Microsoft.AspNetCore version 2.2.0 (added to https://github.com/WireMock-Net/WireMock.Net/tree/master/examples/WireMock.Net.Console.NETCoreApp2) and it works ok.

I get a file not found error deep within kestrel server start. It is a also a silent fail so although the mock server starts, it doesnt respond to any requests on the port.

@megha222 commented on GitHub (Jun 11, 2019): > I did a quick test with Microsoft.AspNetCore version 2.2.0 (added to https://github.com/WireMock-Net/WireMock.Net/tree/master/examples/WireMock.Net.Console.NETCoreApp2) and it works ok. I get a file not found error deep within kestrel server start. It is a also a silent fail so although the mock server starts, it doesnt respond to any requests on the port.
Author
Owner

@megha222 commented on GitHub (Jun 19, 2019):

This was a mistake in our application reference assembly bindings. Sorry its a non-issue. It works with Kestrel 2.2.0 as well. Closing this issue. Thanks

@megha222 commented on GitHub (Jun 19, 2019): This was a mistake in our application reference assembly bindings. Sorry its a non-issue. It works with Kestrel 2.2.0 as well. Closing this issue. 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#174