cloudconvert / cloudconvert-java

Official CloudConvert Java SDK
35 stars 19 forks source link

SocketException: Connection reset #42

Open tonysimpson-sonocent opened 2 years ago

tonysimpson-sonocent commented 2 years ago

Hi, we're seeing a few "java.net.SocketException: Connection reset" exception in our logs coming from cloudconvert-java.

We think these are being caused because PoolingHttpClientConnectionManager is being used without a timeToLive and your API does not return a keep-alive or Connection: close headers so PoolingHttpClientConnectionManager will expect connection can stay open forever.

We will probably work around this for how by creating a new client every request.

I had a look at the cloudconvert-python client, it does not reuse connections.

Honestly I'm not sure what the best fix is. Giving PoolingHttpClientConnectionManager a timeToLive or returning a keep-alive header of something sensible like 1 hour would probably eliminate these errors for us. However in my experience in corporate networks environments overloaded or misconfigured routers will reset (RST) connections after only a few minutes.

josiasmontag commented 2 years ago

We would like to keep the possibility to reuse connections. If there are a lot of API requests it reduces the overhead of the connection establishment, TLS handshake etc. significantly.

We have heard of this "Connection reset" problems from other customers but we are not sure why exactly this is happening. Could you test if setting timeToLive to 1h would solve this issue?

jwgmeligmeyling commented 1 year ago

We are experiencing this issue as well.

johannes-isaksson commented 1 year ago

I, too, am having this problem.