locked
Webservice could not returned a value due to server request timeout. RRS feed

  • Question

  • User719557214 posted

    HI

    I have created an asmx webservice.In which my one method will wait in blocking mode for receiving from socket.

    Normally it is working fine but when i got request timeout from webserver  where i have hosted the service .The receive will is not able to return value to the client and hence my application hangs.

    Is there any way to get any exception or notification so that i can re initiate my receive operation at client.

    Tuesday, July 16, 2013 12:40 AM

Answers

  • User516094431 posted

    But if client is not connected how service will notify by throwing exception or by return value.

    Do 2 steps:

    Step 1: Check webservice is connected or not. In case not connected then show user define error msg.

    public bool CheckURLOnlineOrNot()

    {

    var ping = new System.Net.NetworkInformation.Ping();

    var result = ping.Send("http://www.chaton.dilipdotnet.com");

    if (result.Status != System.Net.NetworkInformation.IPStatus.Success)
            return false;
    return true;

    }

    OR:


    public bool CheckURLOnlineOrNot()

    {
    HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create("http://www.chaton.dilipdotnet.com");
    httpReq.AllowAutoRedirect = false;

    HttpWebResponse httpRes = (HttpWebResponse)httpReq.GetResponse();

    if (httpRes.StatusCode==HttpStatusCode.NotFound) 
    {
    httpRes.Close();
    return false;
    }

    // Close the response.
    httpRes.Close();
    return true;
    }

    Step 2: If webservice is connected then do error handling for request time out. Throw exception from webservice and catch in your.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 16, 2013 12:09 PM

All replies

  • User516094431 posted

    Check below link, may be it'll helpfull for you:

    Implementation of Connecting a Socket with Timeout in C#

    http://www.codeproject.com/Articles/31514/Implementation-of-Connecting-a-Socket-with-Timeout

    Tuesday, July 16, 2013 12:57 AM
  • User719557214 posted

    Hi,

    My actual issue is that when i call service function it is connected and it waits at service in blocking for receive.As i receive something my service disconneted from client.and service function is not able to reply. That's why my receive call is blocked.It is not even giving any exception.

    Tuesday, July 16, 2013 1:25 AM
  • User516094431 posted

    Try This:

    <configuration>

       <system.web>

        <httpRuntime executionTimeout="51600"/>

       </system.web>

    </configuration>

    OR:

    You can use the following method to increase the webservice timeout.

    You can modify the machine.config file, and find the node of httpruntime, and configure the executetimeout value.

    Here is the link.

     http://msdn.microsoft.com/en-us/library/e1f13641.aspx   

    And set the timeout at calling the webservice.

    WebReference.Service   ser   =   new   WebReference.Service();   
    ser.Timeout   =   36000;

    Refer From:

    http://forums.asp.net/t/1256954.aspx


    Tuesday, July 16, 2013 1:47 AM
  • User719557214 posted

    Ya i am doing that only but in my case my server on which i have hosted server having some problem in its internet connection so its giving request timeout in every 20-30 mins.For that handling i need the notification.

    Tuesday, July 16, 2013 1:52 AM
  • User516094431 posted

    For that handling i need the notification.

    I Think it's simple:

    http://forums.asp.net/t/1209657.aspx/1

    If am not wrong.

    Tuesday, July 16, 2013 3:58 AM
  • User719557214 posted

    But if client is not connected how service will notify by throwing exception or by return value.

    Tuesday, July 16, 2013 4:22 AM
  • User516094431 posted

    But if client is not connected how service will notify by throwing exception or by return value.

    Do 2 steps:

    Step 1: Check webservice is connected or not. In case not connected then show user define error msg.

    public bool CheckURLOnlineOrNot()

    {

    var ping = new System.Net.NetworkInformation.Ping();

    var result = ping.Send("http://www.chaton.dilipdotnet.com");

    if (result.Status != System.Net.NetworkInformation.IPStatus.Success)
            return false;
    return true;

    }

    OR:


    public bool CheckURLOnlineOrNot()

    {
    HttpWebRequest httpReq = (HttpWebRequest)WebRequest.Create("http://www.chaton.dilipdotnet.com");
    httpReq.AllowAutoRedirect = false;

    HttpWebResponse httpRes = (HttpWebResponse)httpReq.GetResponse();

    if (httpRes.StatusCode==HttpStatusCode.NotFound) 
    {
    httpRes.Close();
    return false;
    }

    // Close the response.
    httpRes.Close();
    return true;
    }

    Step 2: If webservice is connected then do error handling for request time out. Throw exception from webservice and catch in your.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 16, 2013 12:09 PM
  • User719557214 posted

    Thanks Shoaib its working now.

    Wednesday, July 17, 2013 4:54 AM