Getting fatal alert: handshake_failure issue on Java 7


#1

Until yesterday I was using BETA_LINK for fetching the Legislators and committees, chambers and districts in Java-7 based project, but got some issue while calling the same this morning, below is the HTTP operation which I’m calling to fetching House/Senate Chamber of all state:

Request

HttpResponse response = Unirest.post(BETA_LINK)
.header(“Content-Type”, “application/graphql”)
.header(“X-API-KEY”, “xxxxxxxxxxxxxxxxxxxxxxxxxx”)
.header(“cache-control”, “no-cache”)
.body("{\njurisdictions {\nedges {\nnode {\nid\nname\norganizations(\nclassification:[“upper”, “lower”],\nfirst:2) {\nedges {\nnode {\nid\nname\nclassification\n} } } } } } }\n\n")
.asString();

Response

{
“errors”: [
{
“message”: “Must provide query string.”
}
]
}

Then later I found that the Base URL is changed PROD_HOST

While using Postman app, I’am able to get the response using same graphql, but from Java-7 based project i’m getting the handshake exception:

{
“message”: “javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure”,
“cause”: “[Ljava.lang.StackTraceElement;@3ed84b36
}

I have even tried with a self signed cert and various Jboss configurations
I’m using Maven project having Jboss-7 as server and Java 7.

Can anyone point out how can I resolve this issue?


#2

Above post was not allowing me to post with below links, So adding here
BETA_LINK beta(dot)openstates.org/graphql
PROD_LINK: openstates(dot)org/graphql


#3

I think it’s supposed to be a .field("query", "{\njurisdictions {\nedges {\nnode {\nid\nname\norganizations(\nclassification:[“upper”, “lower”],\nfirst:2) {\nedges {\nnode {\nid\nname\nclassification\n} } } } } } }\n\n"), not a .body(...).


#4

I don’t know unirest, and my Java is rusty, so I can’t speak directly to your problem. The query must be in a query member of the body json, one level down from where you have it. See

for a cURL example.


#5

Also, it is likely that the reason you are getting a failure with the old URL in Java is that your code isn’t handling a 301 (Moved Permanently) response, but Postman is. I suspect you can see the full interaction somewhere in the Postman UI. It’s probably nothing to worry about - just use the new URL.


#6

still getting the same issue.


#7

Can you clarify? Are you seeing the “Must provide query string” or the “handshake_failure”, or both? What did you try?


#8

I’m getting “handshake_failure” exception using NEW_URL in the Java program while calling CURL operation in it by using JAVA-7


#9

Are you using the http or the https URL? If http, I’d try switching to https, that is:

https://openstates.org/graphql/

In this case as well, using the wrong URL results in a redirect that you’re probably not handling.


#10

You might consider emulating example 2 at https://www.programcreek.com/java-api-examples/?api=com.mashape.unirest.request.HttpRequestWithBody with regard to body construction and headers Content-type and accept. Also, see doc at https://graphql.org/learn/serving-over-http/#post-request

I have never gotten Content-Type “application/graphql” to work, support for it is spotty, and it doesn’t support variables.


#11

@Mradul what ended up happening for you with this?


#12

This topic was automatically closed 70 days after the last reply. New replies are no longer allowed.