Caused by: java.net.SocketException: Connection reset Error
Attached a typical error instance.
Client side:
[2020-02-17T09:36:51.240Z] Downloading 'https://<URL>'
...
threw an exception: java.io.IOException: Could not create or write to file
...
[2020-02-17T09:36:52.643Z] Caused by: java.net.SocketException: Connection reset
This is happening multiple times a day - what could be causing this and how can it be fixed?
2 Replies
After digging around on this for a bit, it sounds like there are a few things to try in terms of adjusting internal configurations.
Per this TIBC post, the "Connection Reset" error was able to be bypassed by having the "customer" add the HTTP header Connection: close
in the actual HTTP request:
This tutorial from Java Code Geeks identified the issue as there being Too many open files
(specifically, too many file descriptors open to the system) on the receiving end. This was solved by going /etc/sysctl.conf
and raising the number in the fs.file-max
field:
java.net.SocketException – How to solve SocketException
Finally, this Stack Overflow forum post provides a few different fixes for this, including tuning the http-thread-pool
settings, looking to see if the HttpClient
is stale, and more:
What's causing my java.net.SocketException: Connection reset?
You can also look to see if an MTR report can help identify if there is any packet loss between servers along the network route:
How can I diagnose a network connectivity issue?
Hope these help!
java.io.IOException: Could not create or write to file
You don't have permission to create/write a file in the directory where you're trying to store the download…or you're trying to create a local-domain socket (file) in a place where you don't have permission to do that.
Caused by: java.net.SocketException: Connection reset
The server has determined that your download is taking too long and terminated it…or your software is hanging up on the server.
Given the first error, I would suggest the latter… Your software determines it can't save the download because of a permissions error or can't create the socket in the first place and then just hangs up.
-- sw