'Socket not created by this factory' with DW v1.1.0

1,811 views
Skip to first unread message

Chris Charlton

unread,
Mar 29, 2017, 10:10:50 AM3/29/17
to dropwizard-user
Hi,
I've been using DW extensively, and now in a production setting since before v0.9, and have gradually been upgrading in line with releases (fabulous product by the way - thanks).

I've had some working code that $HTTP POST's a JPEG as part of a multipart form (posted from an Angular 1.3 javascript form) that worked fine with DW 1.0.5. The server side code took the uploaded file and did a putObject into an Amazon S3 bucket (using the s3client). Upgrading to DW1.1.0, this POST threw an error, and the top part of the stacktrace runs:

ERROR [2017-03-29 13:23:52,058] io.dropwizard.jersey.errors.LoggingExceptionMapper: Error handling a request: 35e00e139e5982e4
! java.lang.IllegalStateException: Socket not created by this factory
! at org.apache.http.util.Asserts.check(Asserts.java:34)
! at org.apache.http.conn.ssl.SSLSocketFactory.isSecure(SSLSocketFactory.java:435)
! at org.apache.http.impl.conn.DefaultClientConnectionOperator.openConnection(DefaultClientConnectionOperator.java:186)
! at org.apache.http.impl.conn.ManagedClientConnectionImpl.open(ManagedClientConnectionImpl.java:326)
! at org.apache.http.impl.client.DefaultRequestDirector.tryConnect(DefaultRequestDirector.java:610)
! at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:445)
! at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:835)
! at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
! at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:56)
! at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:822)
! at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:576)
! at com.amazonaws.http.AmazonHttpClient.doExecute(AmazonHttpClient.java:362)
! at com.amazonaws.http.AmazonHttpClient.executeWithTimer(AmazonHttpClient.java:328)
! at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:307)
! at com.amazonaws.services.s3.AmazonS3Client.invoke(AmazonS3Client.java:3659)
! at com.amazonaws.services.s3.AmazonS3Client.putObject(AmazonS3Client.java:1422)
! at com.novel.cm.resources.CMResource.uploadPhoto(CMResource.java:2328)

The issue appears  to be with the connection related with the S3 bucket (is it now demanding a  connection over SSL?)

Reverting to 1.0.5 made the problem go away. 

Any thoughts? Has some validation become overly strict (the aAsserts.check?)

Thanks
Chris

Steve Kradel

unread,
Mar 29, 2017, 3:31:46 PM3/29/17
to dropwizard-user
This wouldn't be related to DW validation--rather, the AWS S3 API has somehow ended up with a handle to a Socket which is not an SSLSocket.

Intuition suggests that DW 1.1 may have introduced a change that interferes with some global / default state in Apache HTTPClient.

It would be useful to know what version of the AWS SDK is in play here...

--Steve

Artem Prigoda

unread,
Mar 30, 2017, 3:54:55 AM3/30/17
to dropwizard-user
Hi Chris,

Do you use the `dropwizard-client` module? We updated it in Dropwizard 1.1.0 to Apache HttpClient 4.5.3 from 4.5.2 and I believe the Amazon SDK depends on the 4.5.2 version: http://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-core/1.11.109. Maybe your Dropwizard application pulls 4.5.3 instead of 4.5.2, and for some reason the Amazon SDK doesn't work with it? I had a quick look at the release notes for 4.5.3 version: http://www.apache.org/dist/httpcomponents/httpclient/RELEASE_NOTES-4.5.x.txt, but couldn't find any obvious clues leading to your issue.

Artem

Chris Charlton

unread,
Apr 14, 2017, 4:41:12 AM4/14/17
to dropwizard-user
Hi Artem,
No, I don't use dropwizard-client (at least not explicitly - it is not listed in the POM) - but you have identified the issue. Upgrading to DW 1.1.0 pulled in the 4.5.3 version of HttpClient causing the upload to Amazon S3 to fail. So I explicitly 'Declared HttpClient 4.5.2 as a direct dependency. This time, DW1.1.0 does not pull in 4.5.3, and all seems to work quite properly.

Thanks for the pointer.
Chris  

Mitul Agrawal

unread,
Jan 14, 2018, 3:09:37 AM1/14/18
to dropwizard-user
Hey, how did you fix this issue ? I updated my HttpClient to 4.5.4 and my aws client started throwing the same exception when I tried to connect to the KMS service. 
Reply all
Reply to author
Forward
0 new messages