• Register
1 vote
41 views

Problem:

I am able to login through webservices api to particular account on 'Oracle on demand'.
When i tries to call 'accountQueryPage' method of the stub class (Stub class is generated with help Account.wsdl file), 

i got the following exception

java.net.SocketException: Software caused connection abort: recv failed

Can anyone give me some pointers.

6.1k points

2 Answers

1 vote

Answer:

SocketException is a general exception the designates a problem when trying to access or open a Socket. 
So as you can imagine, solving that problem has to be done with extra care. 
You shall always log the error message that accompanies the exception. 
In the previous example we’ve seen the message code>Connection reset. 
This happens when on of the participants “violently” closes the connection without using close(). 
This means that you should check whether one of the participants has terminated unexpectedly. 
One slightly bizarre message can be Too many open files, especially when you run on Linux. 
This message designates that to many file descriptors are open to the system. 
You can avoid that error if you go to /etc/sysctl.conf and raise the number in fs.file-max field. 
Additionally, you can try to give more stack memory.

Of course many other messages can be met. For example "Bind error", 
where your connection cannot be established because the port cannot be bind to the socket. In that case check if the port is already in use etc.

Hope this helps.

34.9k points
0 votes

Solution:

This generally refers that there was a network error, like a TCP timeout. I would begin by fixing a sniffer (wireshark) on the connection to see in case you can see any problems. In case there is a TCP error, you must be able to see it. Further, you can inspect your router logs, in case this is applicable. In case wireless is engaged anywhere, that is another source for these kind of errors.

This also occurs in case your TLS client is unable to be authenticate by the server configured to claim client authentication.

This error happens when a connection is closed abruptly (when a TCP connection is reset while there is still data in the send buffer). The condition is very same to a much more usual 'Connection reset by peer'. It can occur sporadically when connecting over the Internet, however also systematically in case the timing is right (for example- with keep-alive connections on localhost).

An HTTP client must only re-open the connection and retry the request. It is significant to understand that when a connection is in this state, there is no way out of it other than to close it. Any try to send or receive will generate the same error.

Don't use URL.open(), employ Apache-Commons HttpClient which has a retry mechanism, connection pooling, keep-alive and few other features.

Example usage:

HttpClient httpClient = HttpClients.custom()
            .setConnectionTimeToLive(20, TimeUnit.SECONDS)
            .setMaxConnTotal(400).setMaxConnPerRoute(400)
            .setDefaultRequestConfig(RequestConfig.custom()
                    .setSocketTimeout(30000).setConnectTimeout(5000).build())
            .setRetryHandler(new DefaultHttpRequestRetryHandler(5, true))
            .build();
// the httpClient should be re-used because it is pooled and thread-safe.

HttpGet request = new HttpGet(uri);
HttpResponse response = httpClient.execute(request);
reader = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));
// handle response ...

Inspect why your client is sending the second request before reading the response of the first request. Find for any multi-threading angle in case the error is alternate.
I have also seen this error while performing with a Java Web application linking to database. At the time  you left  your application overnight and there is no request to scheme during the night, in the morning it was casting "java.sql.SQLException: Communication link failure: java.net.SocketException, underlying reason: Software involved connection abort: recv failed" error.
The real reason of the problem was that database timed out the connection at the time left idle and when Java application attempts to link to the database employing those stale connection it throws java.sql.SQLException: Communication link failure: java.net.SocketException, underlying reason: Software caused connection abort: recv failed error.

Because we were employing the c3po connection pool from Hibernate and enabled connection.autoReconnect, connection.autoReconnectForPools, and connection.is-connection-validation-required set, I was surprising why this issue is coming even in case we auto connect enabled.  The real cause was that we have not provided the validationQuery property and JDBC drivers require validation query to test the connection at the time the idle period.
You can exercise queries like "SELECT 1" or "SELECT 1 from DUAL" relying upon which database you are connecting In our instance, it was Microsoft SQL SERVER 2008 however this error can occur with any database for example MySQL or Oracle. Exercise the second validation query in case you are linking to Oracle database from Java application employing the c3p0 connection pool.

In case you are not using c3p0 however employing Apache DBCP connection pool for example employing org.apache.commons.dbcp.BasicDataSource  in your Spring config file then uses topical property so that JDBC connection pool can automatically test the pooled database connection.

That's all about java.net.SocketException: Software caused connection abort: recv failed". You see the origin reason is that one party, generally the server has closed the connection however the client is attempting to read from that connection. I understand the every condition is diverse and it may claim different solution however knowing this fundamental will help you to shortly troubleshoot your issue.
 

17.3k points
edited by

Related questions

2 votes
1 answer 24 views
24 views
Problem: I am able to login through webservices api to particular account on 'Oracle on demand'. When i tries to call 'accountQueryPage' method of the stub class (Stub class is generated with help Account.wsdl file), i got the following exception java.net.SocketException: Software caused connection abort: recv failed Can anyone give me some pointers.
asked Mar 24 LizzyM 6.1k points
0 votes
1 answer 210 views
210 views
Problem : I am getting bellow error while using Sockets java.net.socketexception: software caused connection abort: socket write error
asked Oct 19, 2019 peterlaw 6.9k points
0 votes
1 answer 56 views
56 views
Problem : I am struggling to find the solution for the bellow error java net socketexception software caused connection abort recv failed
asked Oct 31, 2019 peterlaw 6.9k points
0 votes
1 answer 27 views
27 views
Problem: I am seeing "{writer,send_failed,{error,closed}}" error on server side and "java.net.SocketException: Connection reset by peer: socket write error" error on java client side intermittently. What could possibly go wrong here? Both server and ... rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:630) at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:621) Please help me.
asked Mar 23 LizzyM 6.1k points
0 votes
1 answer 123 views
123 views
Problem : I am trying to implement an HTTP Server using Sockets but getting bellow error java net socketexception connection reset by peer socket write error
asked Oct 31, 2019 peterlaw 6.9k points