3

I am running the following query

SELECT Id, ParentId, Name, ContentType, BodyLength, Body, OwnerId, CreatedDate, CreatedById, LastModifiedDate, LastModifiedById, SystemModstamp FROM Attachment 

using query option in my Sandbox environment. The sandbox is similar to production where there are about 300k records. The usual query runs for about 4 hours. When I tried running this for a few more trials, there was data being returned but after a few hours, I get the following error:

com.sforce.ws.ConnectionException: Failed to send request to https://cs7.salesforce.com/services/Soap/u/33.0/00Xe0000008CuJl
    at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:121)
    at com.sforce.soap.partner.PartnerConnection.queryMore(PartnerConnection.java:593)
    at sflayer.SOAPDataReader.queryAll(SOAPDataReader.java:277)
    at sflayer.SOAPDataReader.run(SOAPDataReader.java:87)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.net.SocketException: Connection reset
    at java.net.SocketInputStream.read(Unknown Source)
    at java.net.SocketInputStream.read(Unknown Source)
    at sun.security.ssl.InputRecord.readFully(Unknown Source)
    at sun.security.ssl.InputRecord.readV3Record(Unknown Source)
    at sun.security.ssl.InputRecord.read(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
    at sun.security.ssl.SSLSocketImpl.readDataRecord(Unknown Source)
    at sun.security.ssl.AppInputStream.read(Unknown Source)
    at java.io.BufferedInputStream.fill(Unknown Source)
    at java.io.BufferedInputStream.read1(Unknown Source)
    at java.io.BufferedInputStream.read(Unknown Source)
    at sun.net.www.http.ChunkedInputStream.fastRead(Unknown Source)
    at sun.net.www.http.ChunkedInputStream.read(Unknown Source)
    at java.io.FilterInputStream.read(Unknown Source)
    at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(Unknown Source)
    at java.util.zip.InflaterInputStream.fill(Unknown Source)
    at java.util.zip.InflaterInputStream.read(Unknown Source)
    at java.util.zip.GZIPInputStream.read(Unknown Source)
    at sun.nio.cs.StreamDecoder.readBytes(Unknown Source)
    at sun.nio.cs.StreamDecoder.implRead(Unknown Source)
    at sun.nio.cs.StreamDecoder.read(Unknown Source)
    at java.io.InputStreamReader.read(Unknown Source)
    at com.sforce.ws.parser.MXParser.fillBuf(MXParser.java:2962)
    at com.sforce.ws.parser.MXParser.more(MXParser.java:3014)
    at com.sforce.ws.parser.MXParser.nextImpl(MXParser.java:1397)
    at com.sforce.ws.parser.MXParser.next(MXParser.java:1111)
    at com.sforce.ws.parser.XmlInputStream.next(XmlInputStream.java:136)
    at com.sforce.ws.bind.XmlObject.loadAfterStartTag(XmlObject.java:282)
    at com.sforce.ws.bind.XmlObject.load(XmlObject.java:268)
    at com.sforce.ws.bind.XmlObject.loadAfterStartTag(XmlObject.java:286)
    at com.sforce.ws.bind.XmlObject.load(XmlObject.java:268)
    at com.sforce.ws.bind.TypeMapper.readSingle(TypeMapper.java:653)
    at com.sforce.ws.bind.TypeMapper.readArray(TypeMapper.java:553)
    at com.sforce.ws.bind.TypeMapper.readObject(TypeMapper.java:531)
    at com.sforce.soap.partner.QueryResult.loadFields(QueryResult.java:146)
    at com.sforce.soap.partner.QueryResult.load(QueryResult.java:130)
    at com.sforce.ws.bind.TypeMapper.readSingle(TypeMapper.java:653)
    at com.sforce.ws.bind.TypeMapper.readObject(TypeMapper.java:529)
    at com.sforce.soap.partner.QueryMoreResponse_element.loadFields(QueryMoreResponse_element.java:64)
    at com.sforce.soap.partner.QueryMoreResponse_element.load(QueryMoreResponse_element.java:56)
    at com.sforce.ws.bind.TypeMapper.readSingle(TypeMapper.java:653)
    at com.sforce.ws.bind.TypeMapper.readObject(TypeMapper.java:529)
    at com.sforce.ws.transport.SoapConnection.bind(SoapConnection.java:174)
    at com.sforce.ws.transport.SoapConnection.receive(SoapConnection.java:148)
    at com.sforce.ws.transport.SoapConnection.send(SoapConnection.java:99)
    ... 6 more

SOAPDataReader.queryAll() is the method that runs the query to use query() SOAP call.

  1. If this happens more frequently, how can I increase idle time?

  2. What would be an optimal way to restart the connection and go back to the previous call from a programming perspective? I'd not prefer calling the same function SOAPDataReader.queryAll() inside the catch(ConnectionException ce).

0

I was able to work around this by building a retrying framework on the caller on this particular exception. Used this library for implementation. A sample snippet in Java would look like:

com.github.rholder.retry.Retryer<Object> retryer = RetryerBuilder.newBuilder().retryIfException(e ->
        {
            boolean retry = false;
            if (e instanceof ConnectionException)
            {
                if ((e instanceof ApiFault) || (StringUtils.contains(ExceptionUtils.getRootCauseMessage(e),
                        ExceptionCode.INVALID_SESSION_ID.toString())))
                    retry = false;
                else
                    retry = true;
            }
            return retry;
        }).build();
QueryResult result = (QueryResult) retryer
                .call(() -> soapConnection.queryMore("queryLocator"));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.