Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
462 views
in Technique[技术] by (71.8m points)

unit testing - PactBroker throws java.net.ConnectException: Operation timed out (Connection timed out)

I have a pact broker server hosted at https://mytestbroker.com. I am able to browse the broker page.

When I run mvn test, the contract test fails with Connection timed out error.

curl -i https://mytestbroker.com
HTTP/1.1 200 OK
Content-Type: application/hal+json;charset=utf-8
Date: Wed, 06 Jan 2021 03:40:58 GMT
Server: nginx/1.13.12
Status: 200 OK
X-Content-Type-Options: nosniff
X-Pact-Broker-Version: 2.29.0
X-Powered-By: Phusion Passenger 6.0.2
Content-Length: 2648
Connection: keep-alive


@PactBroker(host = "mytestbroker.com", scheme = "https", consumers = {"my-api"})
@Provider("backend1")
public class MyContractTest {
  @State("do some action")
  public void testBackendService1() {    
  }
}

org.apache.http.conn.HttpHostConnectException: Connect to mytestbroker.com:443 [mytestbroker.com/2.2.2.2, mytestbroker.com/5.5.5.5] failed: Operation timed out (Connection timed out)
Caused by: java.net.ConnectException: Operation timed out (Connection timed out)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The error seems unrelated to Pact, and more about networking.

Is the broker publicly accessible? How is the test itself run? Are their intermediate proxies that cURL knows about that the Java process doesn't?

You should enable debug level logging to see what Pact sees.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...