Can't run consumer tests via command line on remote server
See original GitHub issueHi,
I can run my pact consumer tests via command line locally but I can’t seem to run the same command on my remote server and keep getting the following error:
**The connection to ‘localhost’ failed.
Error: ConnectionRefused (0x274d).
System.Net.Sockets.SocketException No connection could be made because the target machine actively refused it 127.0.0.1:9222
Stack Trace: at PactNet.Mocks.MockHttpService.AdminHttpClient.SendAdminHttpRequest[T](HttpVerb method, String path, T requestContent, IDictionary`2 headers) in C:\projects\pact-net\PactNet\Mocks\MockHttpService\AdminHttpClient.cs:line 80 at PactNet.Mocks.MockHttpService.MockProviderService.SendAdminHttpRequest(HttpVerb method, String path) in C:\projects\pact-net\PactNet\Mocks\MockHttpService\MockProviderService.cs:line 130 at PactNet.PactBuilder.Build() in C:\projects\pact-net\PactNet\PactBuilder.cs:line 115
----- Inner Stack Trace -----
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)
at System.Threading.Tasks.ValueTask1.get_Result() at System.Net.Http.HttpConnectionPool.CreateConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken) at System.Threading.Tasks.ValueTask
1.get_Result()
at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask1 creationTask) at System.Threading.Tasks.ValueTask
1.get_Result()
at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.FinishSendAsyncBuffered(Task`1 sendTask, HttpRequestMessage request, CancellationTokenSource cts, Boolean disposeCts)
----- Inner Stack Trace -----
at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)**
There are no firewall or anti-virus rules preventing the app as far as I can see, I’ve even opened up the port in question via inbound and outbound firewall rules but to no avail. The app is simply not able to open a port (9222 or any other port number I specify) for some reason to start making http requests to the mock provider client to create pact files.
Is there anything else that could be preventing these tests from running?
Thanks, Billy
Issue Analytics
- State:
- Created 4 years ago
- Comments:14 (5 by maintainers)
Top GitHub Comments
I have been able to go around the issue by manually installing and starting up the pact mock service via https://github.com/pact-foundation/pact-mock_service:
sudo pact-mock-service --consumer "ConsumerName" --provider "ProviderName" --port 9222 --pact-dir "./pacts" --log ./pacts/mock_service.log --pact-specification-version 2
When running the tests, and connecting the MockServer to localhost:9222, I no longer receive the HttpRequestExceptions, and my pacts are being build correctly.
Glad you got this sorted 👍