function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sd2008sd2008 

System.CalloutException: IO Exception: Read timed out?

I have a webservice it runs fine, but it takes a while to get a response because it loads lots of data.

when it callout from an apex class from salesforce, it always return : System.CalloutException: IO Exception: Read timed out.

 

Is there a property to set the time out period of the salesforce?

How do we address this problem?

Best Answer chosen by Admin (Salesforce Developers) 
shillyershillyer
Here's an example of setting a custom timeout for Web services callouts:
docSample.DocSamplePort stub = new docSample.DocSamplePort();
stub.timeout_x = 2000; // timeout in milliseconds

Hope that helps,

Sati

All Answers

shillyershillyer
Here's an example of setting a custom timeout for Web services callouts:
docSample.DocSamplePort stub = new docSample.DocSamplePort();
stub.timeout_x = 2000; // timeout in milliseconds

Hope that helps,

Sati

This was selected as the best answer
apurswaniapurswani

I am also facing the same problem. While calling webservice from apex it is showing the error.

 

Here is the .Net Web Service code which returns just "Hello World" String:-

 

    public class Service1 : System.Web.Services.WebService
    {
        [WebMethod]
        public string HelloWorld()
        {
            return "Hello World";
        }
    }

 

 

Now I tried to call this using APEX as follows: -

 

global class HelloWorld
{

    webService static String sampleCSharpWebServiceCall()
    {
        String retVal;
        TestWebServiceForAPEX.Service1Soap csService = new TestWebServiceForAPEX.Service1Soap();
        csService.timeout_x = 90000;
        retVal = csService.HelloWorld();
        return retVal;
    }

}

 

 

Now I generated wsdl and used it in another .Net Web Application on code behind of button click I am calling APEX Method which will in turn call other WebService written in .Net

 

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                SforceService sfs = new SforceService();
                sfs.Timeout = 90000;

                LoginResult lr = sfs.login("username", "passwordtoken");

                HelloWorldService hws = new HelloWorldService();
                hws.Timeout = 90000;
                
                hws.SessionHeaderValue = new TestWebCSharpWebService.SessionHeader();
                hws.SessionHeaderValue.sessionId = lr.sessionId;

                TextBox1.Text = hws.sampleCSharpWebServiceCall();

            }
            catch (SoapException ex)
            {
                TextBox1.Text = ex.Message;
            }

     }

 


But it is showing following error:-

 

System.CalloutException: IO Exception: Read timed out
Class.TestWebServiceForAPEX.Service1Soap.HelloWorld: line 28, column 13
Class.HelloWorld.sampleCSharpWebServiceCall: line 33, column 15
External entry point

 

 

AnzarCRMAnzarCRM

Hi,

 

How have you resolved this issue ?

 

All the best,

 

Anzar.

FrankCabrejaFrankCabreja

Sati (Shillyer),

 

Your response led me to the final answer. But what was misleading was the 2000 millisecond value you assigned.

 

I used the Developer Console in Salesforce and the Timeline feature for the particular class that calledout to the webservice for Docusign and noticed that the some callouts were taking more than 5000 milliseconds, which is what I had assigned to the timeout_x property. Governor limits specify that the maximum is 120 seconds or 120,000 milliseconds. I set the timeout_x to 100,000 and I have had no further problems.

RangavalliRangavalli

Hi Shillyer,

 

Can please explain the how are you initializing the class docsample and so on. I am starter in the salesforce and i want to learn it could you, please provide me the explanation to increase the timeout value.

 

docSample.DocSamplePort stub = new docSample.DocSamplePort();
stub.timeout_x = 2000; // timeout in milliseconds

 

 

Thanks in Advance