pact-foundation / pact-jvm

JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project.
https://docs.pact.io
Apache License 2.0
1.07k stars 475 forks source link

Pact broker RequestFailedException HTTP/1.1 400 Bad Request #1252

Closed YingzheHeBetty closed 3 years ago

YingzheHeBetty commented 3 years ago

Hi,

I am using a secured pact broker to fetch pacts on my provider side. The dependency I am using is: au.com.dius.pact.provider:spring:4.1.9

In the code I used PactBroker annotation:

@RunWith(SpringRestPactRunner.class)
@PactBroker(scheme = "https", host = HOSTOFTHEPACTBROKER, port = "443")
@Provider("Analytics Service")
@VerificationReports(value = {"json"})
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, classes = {AnalyticsApplication.class})

I got RequestFailedException saying I am using http instead of https:

**au.com.dius.pact.core.pactbroker.RequestFailedException: Request to path 'http://HOSTOFTHEPACTBROKER:443/pacts/provider/Analytics%20Service/latest' failed with response 'HTTP/1.1 400 Bad Request'**
    at au.com.dius.pact.core.pactbroker.HalClient.handleHalResponse(HalClient.kt:301)
    at au.com.dius.pact.core.pactbroker.HalClient.access$handleHalResponse(HalClient.kt:140)
    at au.com.dius.pact.core.pactbroker.HalClient$getJson$1.invoke(HalClient.kt:284)
    at au.com.dius.pact.core.pactbroker.HalClient$getJson$1.invoke(HalClient.kt:140)
    at au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:36)
    at au.com.dius.pact.core.pactbroker.HalClient.getJson(HalClient.kt:278)
    at au.com.dius.pact.core.pactbroker.HalClient.fetch(HalClient.kt:242)
    at au.com.dius.pact.core.pactbroker.HalClient.fetchLink(HalClient.kt:310)
    at au.com.dius.pact.core.pactbroker.HalClient.navigate(HalClient.kt:231)
    at au.com.dius.pact.core.pactbroker.PactBrokerClient.fetchConsumers(PactBrokerClient.kt:116)
    at au.com.dius.pact.core.pactbroker.PactBrokerClient$fetchConsumersWithSelectors$1.invoke(PactBrokerClient.kt:179)
    at au.com.dius.pact.core.pactbroker.PactBrokerClient$fetchConsumersWithSelectors$1.invoke(PactBrokerClient.kt:103)
    at au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:36)
    at au.com.dius.pact.core.pactbroker.PactBrokerClient.fetchConsumersWithSelectors(PactBrokerClient.kt:176)
    at au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.loadPactsForProvider(PactBrokerLoader.kt:194)
    at au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.load(PactBrokerLoader.kt:111)
    at au.com.dius.pact.provider.junit.PactRunner.initialize(PactRunner.kt:88)
    at au.com.dius.pact.provider.junit.PactRunner.getChildren(PactRunner.kt:143)
    at org.junit.runners.ParentRunner.getFilteredChildren(ParentRunner.java:426)
    at org.junit.runners.ParentRunner.getDescription(ParentRunner.java:351)
    at com.intellij.junit4.JUnit4IdeaTestRunner.getDescription(JUnit4IdeaTestRunner.java:78)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:50)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)

Can somebody take a look and provide some insights? Thanks a lot!

mefellows commented 3 years ago

I think this is a known issue with that version of Pact JVM where the auth header was provided twice. Are you using the latest version?

YingzheHeBetty commented 3 years ago

I think this is a known issue with that version of JVM where the auth header was provided twice. Are you using the latest version?

When I typed java -version, I got: openjdk version "11.0.9" 2020-10-20 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.9+11) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.9+11, mixed mode)

mefellows commented 3 years ago

Sorry, I meant Pact JVM (not the JVM itself)!

YingzheHeBetty commented 3 years ago

Sorry, I meant Pact JVM (not the JVM itself)!

I used au.com.dius.pact.provider:spring:4.1.9.

mefellows commented 3 years ago

Yes, you provided that in the description. In any case, my point was that you may want to try the latest version of that artifact (I think it's 4.1.11 but best you check for yourself), as I think it was an issue that was recently fixed.

YingzheHeBetty commented 3 years ago

Yes, you provided that in the description. In any case, my point was that you may want to try the latest version of that artifact (I think it's 4.1.11 but best you check for yourself), as I think it was an issue that was recently fixed.

I have tried au.com.dius.pact.provider:spring:4.1.11 as well as au.com.dius.pact.provider:spring:4.2.0-beta.1, but the same issue occurred.

mefellows commented 3 years ago

Hmm, this is the commit that I think fixed the issue I'm thinking of: https://github.com/pact-foundation/pact-jvm/commit/940fc83c575fe0565be4c1213244aa8e8229e246. It looks like it's been released, so perhaps it's in a different dependency (i.e. not the spring one). Have you tried updating all of your dependencies?

Is this a new problem that's just been introduced, or have you never been able to get it to work?

Is there authentication on your setup at all (e.g. via environment variables or system properties)? You say secured, please provide more information on what you mean by that.

Are you hosting your own pact broker or using something like Pactflow?

If your own, have you looked at https://docs.pact.io/pact_broker/configuration/#running-the-broker-behind-a-reverse-proxy?

Failing that, you're going to need a way (code, logs and and example setup we can use) to reproduce the exact problem you have so that a maintainer can look at it.

NOTE: I should say that I'm not a maintainer of this repo, somebody else may have more specific info

YingzheHeBetty commented 3 years ago

Hmm, this is the commit that I think fixed the issue I'm thinking of: 940fc83. It looks like it's been released, so perhaps it's in a different dependency (i.e. not the spring one). Have you tried updating all of your dependencies?

Is this a new problem that's just been introduced, or have you never been able to get it to work?

Is there authentication on your setup at all (e.g. via environment variables or system properties)? You say secured, please provide more information on what you mean by that.

Are you hosting your own pact broker or using something like Pactflow?

If your own, have you looked at https://docs.pact.io/pact_broker/configuration/#running-the-broker-behind-a-reverse-proxy?

Failing that, you're going to need a way (code, logs and and example setup we can use) to reproduce the exact problem you have so that a maintainer can look at it.

NOTE: I should say that I'm not a maintainer of this repo, somebody else may have more specific info

  1. The only dependency I use related to the pact is the one that I posted.
  2. I think this is new because I have successfully fetch pact using this pact broker once.
  3. There is no authentication set up. By secured I mean the host server has a self-signed certificate and I have already added the cer to the JVM truststore.
  4. I am using the pact broker server that is set up by ProdOps. So I might need to contact them for the details.

But could you please first test it by usinging another pact broker that has a self-signed certificate? Steps to reproduce:

  1. in build.gradle file: add pact dependency testImplementation 'au.com.dius.pact.provider:spring:4.1.11'
  2. in provider code, add pact annotations: @RunWith(SpringRestPactRunner.class) @PactBroker(scheme = "https", host = HOSTOFTHEPACTBROKER, port = "443") @Provider("Analytics Service") @VerificationReports(value = {"json"}) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT, classes = {AnalyticsApplication.class})
  3. 
    Expected result: can fetch pact from the pact broker
    Actual result: au.com.dius.pact.core.pactbroker.RequestFailedException: Request to path 'http://HOSTOFTHEPACTBROKER:443/pacts/provider/Analytics%20Service/latest' failed with response 'HTTP/1.1 400 Bad Request'


Please let me know what else I can provide for reproducing the issue.
Thank you for your help! 
uglyog commented 3 years ago

If you enable debug logs, the actual requests made to the broker will be logged. If you can provide those, we may be able to diagnose what the issue is.

YingzheHeBetty commented 3 years ago

If you enable debug logs, the actual requests made to the broker will be logged. If you can provide those, we may be able to diagnose what the issue is.

Here are the logs:


14:03:41.670 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - Starting handshake
14:03:41.830 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory - Secure session established
14:03:41.830 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory -  negotiated protocol: TLSv1.2
14:03:41.830 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory -  negotiated cipher suite: TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
14:03:41.830 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory -  peer principal: CN=pact-broker.prod.ourcentro.net
14:03:41.830 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory -  peer alternative names: [pact-broker.prod.ourcentro.net]
14:03:41.830 [main] DEBUG o.a.h.c.s.SSLConnectionSocketFactory -  issuer principal: CN=Let's Encrypt Authority X3, O=Let's Encrypt, C=US
14:03:41.830 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connection established 172.27.252.143:51556<->54.70.13.139:443
14:03:41.830 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Executing request GET / HTTP/1.1
14:03:41.830 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED
14:03:41.830 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
14:03:41.830 [main] DEBUG org.apache.http.headers - http-outgoing-1 >> GET / HTTP/1.1
14:03:41.830 [main] DEBUG org.apache.http.headers - http-outgoing-1 >> Content-Type: application/json
14:03:41.830 [main] DEBUG org.apache.http.headers - http-outgoing-1 >> Accept: application/hal+json, application/json
14:03:41.830 [main] DEBUG org.apache.http.headers - http-outgoing-1 >> Host: pact-broker.prod.ourcentro.net:443
14:03:41.830 [main] DEBUG org.apache.http.headers - http-outgoing-1 >> Connection: Keep-Alive
14:03:41.830 [main] DEBUG org.apache.http.headers - http-outgoing-1 >> User-Agent: Apache-HttpClient/4.5.10 (Java/11.0.9)
14:03:41.830 [main] DEBUG org.apache.http.headers - http-outgoing-1 >> Accept-Encoding: gzip,deflate
14:03:41.830 [main] DEBUG org.apache.http.wire - http-outgoing-1 >> "GET / HTTP/1.1[\r][\n]"
14:03:41.830 [main] DEBUG org.apache.http.wire - http-outgoing-1 >> "Content-Type: application/json[\r][\n]"
14:03:41.830 [main] DEBUG org.apache.http.wire - http-outgoing-1 >> "Accept: application/hal+json, application/json[\r][\n]"
14:03:41.830 [main] DEBUG org.apache.http.wire - http-outgoing-1 >> "Host: pact-broker.prod.ourcentro.net:443[\r][\n]"
14:03:41.831 [main] DEBUG org.apache.http.wire - http-outgoing-1 >> "Connection: Keep-Alive[\r][\n]"
14:03:41.831 [main] DEBUG org.apache.http.wire - http-outgoing-1 >> "User-Agent: Apache-HttpClient/4.5.10 (Java/11.0.9)[\r][\n]"
14:03:41.831 [main] DEBUG org.apache.http.wire - http-outgoing-1 >> "Accept-Encoding: gzip,deflate[\r][\n]"
14:03:41.831 [main] DEBUG org.apache.http.wire - http-outgoing-1 >> "[\r][\n]"
14:03:41.905 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "HTTP/1.1 200 OK[\r][\n]"
14:03:41.905 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "Date: Tue, 01 Dec 2020 19:03:41 GMT[\r][\n]"
14:03:41.905 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "Content-Type: application/hal+json;charset=utf-8[\r][\n]"
14:03:41.905 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "Content-Length: 3290[\r][\n]"
14:03:41.905 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "Connection: keep-alive[\r][\n]"
14:03:41.905 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "Vary: Accept[\r][\n]"
14:03:41.905 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "Server: Webmachine-Ruby/1.5.0 Rack/1.3[\r][\n]"
14:03:41.905 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "X-Pact-Broker-Version: 2.57.0[\r][\n]"
14:03:41.905 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "X-Content-Type-Options: nosniff[\r][\n]"
14:03:41.905 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "[\r][\n]"
14:03:41.905 [main] DEBUG org.apache.http.wire - http-outgoing-1 << "{"_links":{"self":{"href":"http://pact-broker.prod.ourcentro.net:443","title":"Index","templated":false},"pb:publish-pact":{"href":"http://pact-broker.prod.ourcentro.net:443/pacts/provider/{provider}/consumer/{consumer}/version/{consumerApplicationVersion}","title":"Publish a pact","templated":true},"pb:latest-pact-versions":{"href":"http://pact-broker.prod.ourcentro.net:443/pacts/latest","title":"Latest pact versions","templated":false},"pb:tagged-pact-versions":{"href":"http://pact-broker.prod.ourcentro.net:443/pacts/provider/{provider}/consumer/{consumer}/tag/{tag}","title":"All versions of a pact for a given consumer, provider and consumer version tag","templated":false},"pb:pacticipants":{"href":"http://pact-broker.prod.ourcentro.net:443/pacticipants","title":"Pacticipants","templated":false},"pb:pacticipant":{"href":"http://pact-broker.prod.ourcentro.net:443/pacticipants/{pacticipant}","title":"Fetch pacticipant by name","templated":true},"pb:latest-provider-pacts":{"href":"http://pact-broker.prod.ourcentro.net:443/pacts/provider/{provider}/latest","title":"Latest pacts by provider","templated":true},"pb:latest-provider-pacts-with-tag":{"href":"http://pact-broker.prod.ourcentro.net:443/pacts/provider/{provider}/latest/{tag}","title":"Latest pacts for provider with the specified tag","templated":true},"pb:provider-pacts-with-tag":{"href":"http://pact-broker.prod.ourcentro.net:443/pacts/provider/{provider}/tag/{tag}","title":"All pact versions for the provider with the specified consumer version tag","templated":true},"pb:provider-pacts":{"href":"http://pact-broker.prod.ourcentro.net:443/pacts/provider/{provider}","title":"All pact versions for the specified provider","templated":true},"pb:latest-version":{"href":"http://pact-broker.prod.ourcentro.net:443/pacticipants/{pacticipant}/latest-version","title":"Latest pacticipant version","templated":true},"pb:latest-tagged-version":{"href":"http://pact-broker.prod.ourcentro.net:443/pacticipants/{pacticipant}/latest-version/{tag}","title":"Latest pacticipant version with the specified tag","templated":true},"pb:webhooks":{"href":"http://pact-broker.prod.ourcentro.net:443/webhooks","title":"Webhooks","templated":false},"pb:webhook":{"href":"http://pact-broker.prod.ourcentro.net:443/webhooks/{uuid}","title":"Webhook","templated":true},"pb:integrations":{"href":"http://pact-broker.prod.ourcentro.net:443/integrations","title":"Integrations","templated":false},"pb:pacticipant-version-tag":{"href":"http://pact-broker.prod.ourcentro.net:443/pacticipants/{pacticipant}/versions/{version}/tags/{tag}","title":"Get, create or delete a tag for a pacticipant version","templated":true},"pb:metrics":{"href":"http://pact-broker.prod.ourcentro.net:443/metrics","title":"Get Pact Broker metrics"},"pb:can-i-deploy-pacticipant-version-to-tag":{"href":"http://pact-broker.prod.ourcentro.net:443/can-i-deploy?pacticipant={pacticipant}&version={version}&to={tag}","title":"Determine if an application can be safely deployed to an environment identified by the given tag","templated":true},"curies":[{"name":"pb","href":"http://pact-broker.prod.ourcentro.net:443/doc/{rel}?context=index","templated":true},{"name":"beta","href":"http://pact-broker.prod.ourcentro.net:443/doc/{rel}?context=index","templated":true}]}}"
14:03:41.906 [main] DEBUG org.apache.http.headers - http-outgoing-1 << HTTP/1.1 200 OK
14:03:41.906 [main] DEBUG org.apache.http.headers - http-outgoing-1 << Date: Tue, 01 Dec 2020 19:03:41 GMT
14:03:41.906 [main] DEBUG org.apache.http.headers - http-outgoing-1 << Content-Type: application/hal+json;charset=utf-8
14:03:41.906 [main] DEBUG org.apache.http.headers - http-outgoing-1 << Content-Length: 3290
14:03:41.906 [main] DEBUG org.apache.http.headers - http-outgoing-1 << Connection: keep-alive
14:03:41.906 [main] DEBUG org.apache.http.headers - http-outgoing-1 << Vary: Accept
14:03:41.906 [main] DEBUG org.apache.http.headers - http-outgoing-1 << Server: Webmachine-Ruby/1.5.0 Rack/1.3
14:03:41.906 [main] DEBUG org.apache.http.headers - http-outgoing-1 << X-Pact-Broker-Version: 2.57.0
14:03:41.906 [main] DEBUG org.apache.http.headers - http-outgoing-1 << X-Content-Type-Options: nosniff
14:03:41.906 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Connection can be kept alive indefinitely
14:03:41.906 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection [id: 1][route: {s}->https://pact-broker.prod.ourcentro.net:443] can be kept alive indefinitely
14:03:41.906 [main] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-1: set socket timeout to 0
14:03:41.906 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection released: [id: 1][route: {s}->https://pact-broker.prod.ourcentro.net:443][total kept alive: 1; route allocated: 1 of 5; total allocated: 1 of 10]
14:03:41.915 [main] DEBUG a.c.d.pact.core.pactbroker.HalClient - Fetching: http://pact-broker.prod.ourcentro.net:443/pacts/provider/Analytics%20Service/latest
14:03:41.915 [main] DEBUG o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: default
14:03:41.915 [main] DEBUG o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context
14:03:41.915 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection request: [route: {}->http://pact-broker.prod.ourcentro.net:443][total kept alive: 1; route allocated: 0 of 5; total allocated: 1 of 10]
14:03:41.916 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection leased: [id: 2][route: {}->http://pact-broker.prod.ourcentro.net:443][total kept alive: 1; route allocated: 1 of 5; total allocated: 2 of 10]
14:03:41.916 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Opening connection {}->http://pact-broker.prod.ourcentro.net:443
14:03:41.916 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connecting to pact-broker.prod.ourcentro.net/54.70.13.139:443
14:03:41.987 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connection established 172.27.252.143:51557<->54.70.13.139:443
14:03:41.987 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Executing request GET /pacts/provider/Analytics%20Service/latest HTTP/1.1
14:03:41.987 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED
14:03:41.987 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED
14:03:41.987 [main] DEBUG org.apache.http.headers - http-outgoing-2 >> GET /pacts/provider/Analytics%20Service/latest HTTP/1.1
14:03:41.987 [main] DEBUG org.apache.http.headers - http-outgoing-2 >> Content-Type: application/json
14:03:41.987 [main] DEBUG org.apache.http.headers - http-outgoing-2 >> Accept: application/hal+json, application/json
14:03:41.987 [main] DEBUG org.apache.http.headers - http-outgoing-2 >> Host: pact-broker.prod.ourcentro.net:443
14:03:41.987 [main] DEBUG org.apache.http.headers - http-outgoing-2 >> Connection: Keep-Alive
14:03:41.987 [main] DEBUG org.apache.http.headers - http-outgoing-2 >> User-Agent: Apache-HttpClient/4.5.10 (Java/11.0.9)
14:03:41.987 [main] DEBUG org.apache.http.headers - http-outgoing-2 >> Accept-Encoding: gzip,deflate
14:03:41.987 [main] DEBUG org.apache.http.wire - http-outgoing-2 >> "GET /pacts/provider/Analytics%20Service/latest HTTP/1.1[\r][\n]"
14:03:41.987 [main] DEBUG org.apache.http.wire - http-outgoing-2 >> "Content-Type: application/json[\r][\n]"
14:03:41.987 [main] DEBUG org.apache.http.wire - http-outgoing-2 >> "Accept: application/hal+json, application/json[\r][\n]"
14:03:41.987 [main] DEBUG org.apache.http.wire - http-outgoing-2 >> "Host: pact-broker.prod.ourcentro.net:443[\r][\n]"
14:03:41.987 [main] DEBUG org.apache.http.wire - http-outgoing-2 >> "Connection: Keep-Alive[\r][\n]"
14:03:41.987 [main] DEBUG org.apache.http.wire - http-outgoing-2 >> "User-Agent: Apache-HttpClient/4.5.10 (Java/11.0.9)[\r][\n]"
14:03:41.987 [main] DEBUG org.apache.http.wire - http-outgoing-2 >> "Accept-Encoding: gzip,deflate[\r][\n]"
14:03:41.987 [main] DEBUG org.apache.http.wire - http-outgoing-2 >> "[\r][\n]"
14:03:42.058 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "HTTP/1.1 400 Bad Request[\r][\n]"
14:03:42.058 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "Server: nginx/1.16.1[\r][\n]"
14:03:42.058 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "Date: Tue, 01 Dec 2020 19:03:42 GMT[\r][\n]"
14:03:42.059 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "Content-Type: text/html[\r][\n]"
14:03:42.059 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "Content-Length: 255[\r][\n]"
14:03:42.059 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "Connection: close[\r][\n]"
14:03:42.059 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "[\r][\n]"
14:03:42.059 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "<html>[\r][\n]"
14:03:42.059 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "<head><title>400 The plain HTTP request was sent to HTTPS port</title></head>[\r][\n]"
14:03:42.059 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "<body>[\r][\n]"
14:03:42.059 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "<center><h1>400 Bad Request</h1></center>[\r][\n]"
14:03:42.059 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "<center>The plain HTTP request was sent to HTTPS port</center>[\r][\n]"
14:03:42.059 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "<hr><center>nginx/1.16.1</center>[\r][\n]"
14:03:42.059 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "</body>[\r][\n]"
14:03:42.059 [main] DEBUG org.apache.http.wire - http-outgoing-2 << "</html>[\r][\n]"
14:03:42.059 [main] DEBUG org.apache.http.headers - http-outgoing-2 << HTTP/1.1 400 Bad Request
14:03:42.059 [main] DEBUG org.apache.http.headers - http-outgoing-2 << Server: nginx/1.16.1
14:03:42.059 [main] DEBUG org.apache.http.headers - http-outgoing-2 << Date: Tue, 01 Dec 2020 19:03:42 GMT
14:03:42.059 [main] DEBUG org.apache.http.headers - http-outgoing-2 << Content-Type: text/html
14:03:42.059 [main] DEBUG org.apache.http.headers - http-outgoing-2 << Content-Length: 255
14:03:42.059 [main] DEBUG org.apache.http.headers - http-outgoing-2 << Connection: close
14:03:42.060 [main] DEBUG o.a.h.i.c.DefaultManagedHttpClientConnection - http-outgoing-2: Close connection
14:03:42.062 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Connection discarded
14:03:42.062 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection released: [id: 2][route: {}->http://pact-broker.prod.ourcentro.net:443][total kept alive: 1; route allocated: 0 of 5; total allocated: 1 of 10]
au.com.dius.pact.core.pactbroker.RequestFailedException: Request to path 'http://pact-broker.prod.ourcentro.net:443/pacts/provider/Analytics%20Service/latest' failed with response 'HTTP/1.1 400 Bad Request'
    at au.com.dius.pact.core.pactbroker.HalClient.handleHalResponse(HalClient.kt:301)
    at au.com.dius.pact.core.pactbroker.HalClient.access$handleHalResponse(HalClient.kt:140)
    at au.com.dius.pact.core.pactbroker.HalClient$getJson$1.invoke(HalClient.kt:284)
    at au.com.dius.pact.core.pactbroker.HalClient$getJson$1.invoke(HalClient.kt:140)
    at au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:36)
    at au.com.dius.pact.core.pactbroker.HalClient.getJson(HalClient.kt:278)
    at au.com.dius.pact.core.pactbroker.HalClient.fetch(HalClient.kt:242)
    at au.com.dius.pact.core.pactbroker.HalClient.fetchLink(HalClient.kt:310)
    at au.com.dius.pact.core.pactbroker.HalClient.navigate(HalClient.kt:231)
    at au.com.dius.pact.core.pactbroker.PactBrokerClient.fetchConsumers(PactBrokerClient.kt:120)
    at au.com.dius.pact.core.pactbroker.PactBrokerClient$fetchConsumersWithSelectors$1.invoke(PactBrokerClient.kt:183)
    at au.com.dius.pact.core.pactbroker.PactBrokerClient$fetchConsumersWithSelectors$1.invoke(PactBrokerClient.kt:107)
    at au.com.dius.pact.core.support.KotlinLanguageSupportKt.handleWith(KotlinLanguageSupport.kt:36)
    at au.com.dius.pact.core.pactbroker.PactBrokerClient.fetchConsumersWithSelectors(PactBrokerClient.kt:180)
    at au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.loadPactsForProvider(PactBrokerLoader.kt:196)
    at au.com.dius.pact.provider.junitsupport.loader.PactBrokerLoader.load(PactBrokerLoader.kt:111)
    at au.com.dius.pact.provider.junit.PactRunner.initialize(PactRunner.kt:96)
    at au.com.dius.pact.provider.junit.PactRunner.getChildren(PactRunner.kt:151)
    at org.junit.runners.ParentRunner.getFilteredChildren(ParentRunner.java:426)
    at org.junit.runners.ParentRunner.getDescription(ParentRunner.java:351)
    at com.intellij.junit4.JUnit4IdeaTestRunner.getDescription(JUnit4IdeaTestRunner.java:78)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:50)
    at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
    at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
    at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)

Hope this information is helpful!

mefellows commented 3 years ago

OK that's helpful.

The pact broker doesn't know it's running on 443 and is returning HAL links with http in it .

You need to configure the reverse proxy that's in front of it with the correct headers - see https://docs.pact.io/pact_broker/configuration/#running-the-broker-behind-a-reverse-proxy. I can see you're using nginx, so that should be quite straightforward to do

YingzheHeBetty commented 3 years ago

Thank you! The problem was the header configuration.