After enabling wire logging, we see that the response is having some hex values ([0x15][0x3][0x1][0x0][0x2][0x2]) at the beginning of response for all failed cases. This explains the ProtocolException, since it's not starting with HTTP. Sample below :
org.apache.commons.httpclient.Wire.wire >> "GET /api/request?id=111 HTTP/1.1[\r][\n]" org.apache.commons.httpclient.Wire.wire >> "Authorization: Basic AAA[\r][\n]" org.apache.commons.httpclient.Wire.wire >> "User-Agent: Jakarta Commons-HttpClient/3.0.1[\r][\n]" org.apache.commons.httpclient.Wire.wire >> "Host:a.b.com:8443[\r][\n]" org.apache.commons.httpclient.Wire.wire >> "[\r][\n]" org.apache.commons.httpclient.Wire.wire << "[0x15][0x3][0x1][0x0][0x2][0x2][\r][\n]" org.apache.commons.httpclient.Wire.wire << "null[\r][\n]" Googling this pattern (15 03 01 00 02 02) , it seems to match with SSL handshake errors (v3 alert, but with last byte missing..from http://bugs.java.com/bugdatabase/view_bug.do?bug_id=4483157) . What could be the reasons for such a response? Thanks, Joseph -----Original Message----- From: Alex, Joseph (Contractor) Sent: Saturday, July 19, 2014 1:42 AM To: HttpClient User Discussion Subject: Intermittent ProtocolException in HttpClient 3.x Hi, We are getting intermittent ProtocolException " failed to respond with a valid HTTP response" when calling a https URL hosted in Tomcat 6.x. This is HTTPClient 3.x and used within an IBM JVM (JDK 6.x) Both client and server are within same organization, just different servers and configuration. Stacktrace below : org.apache.commons.httpclient.ProtocolException: The server a.b.com failed to respond with a valid HTTP response at org.apache.commons.httpclient.HttpMethodBase.readStatusLine(HttpMethodBase.java:1846) at org.apache.commons.httpclient.HttpMethodBase.readResponse(HttpMethodBase.java:1590) at org.apache.commons.httpclient.HttpMethodBase.execute(HttpMethodBase.java:995) at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:397) at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:170) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:396) at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:324) From HTTPClient source, this is thrown here : else if (s == null || count >= maxGarbageLines) { // Giving up throw new ProtocolException("The server " + conn.getHost() + " failed to respond with a valid HTTP response"); } I assume this means a connection has been established ,and a response returned , but it's just not valid and at some point it becomes null. Is this a right assumption, and how do we go about debugging. Is this related to the URL being HTTPS , and why does it happen only intermittently. During these errors, we don’t see entries in the server's access log, which indicates the request hasn't been processed. Thanks, Joseph This message, including any attachments, is the property of Sears Holdings Corporation and/or one of its subsidiaries. It is confidential and may contain proprietary or legally privileged information. If you are not the intended recipient, please delete it without reading the contents. Thank you.
