question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't run consumer tests via command line on remote server

See original GitHub issue

Hi,

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.ValueTask1.get_Result() at System.Net.Http.HttpConnectionPool.WaitForCreatedConnectionAsync(ValueTask1 creationTask) at System.Threading.Tasks.ValueTask1.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:closed
  • Created 4 years ago
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
KennyDMcommented, Mar 11, 2021

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.

0reactions
adamrodgercommented, Aug 26, 2021

Glad you got this sorted 👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

Run a command on remote machine using powershell
I have a command to be executed on a remote machine using powershell. (Had tried using PsExec. But can't execute commands on a...
Read more >
Unable to get a remote Powershell script running - Forum
On the SAM server, open a command prompt as an Administrator. To do this, perform the following step: Go to the Start menu...
Read more >
Unable to run remote command through Powershell
Solved: Details : I'm attempting to setup a Run Powershell workflow activity to run a command line utility on a remote server. The...
Read more >
Kafka - Unable to send a message to a remote server using ...
I'm trying to create a Kafka cluster to send messages to a remote control. I have configured everything as described here. I am...
Read more >
Understanding and troubleshooting WinRM connection and ...
Here are the key issues that can prevent connection attempts to a WinRM endpoint: The Winrm service is not running on the remote...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found