Error timeout from asp.net 4.5 mvc to WCF service

Gabriel Dos Santos 21 Reputation points
2022-11-15T21:03:19.83+00:00

I have an asp.net mvc 4.5 app that makes requests to a WCF service, the problem is that when the service takes more than 30 seconds the mvc cuts the connection to the service, the wcf service keeps running and makes the changes to the database and returns what it should return, but I can't reflect it on the frontend because of the 502 error

I have already added the executionTimeout="300" in the mvc and it still does not work.

A detail is that the local request works normally, but when deployed is when the error appears.

I also followed the steps of:

"Internet Information Services dialog box, expand local computer > Sites and right click Default Website and select Manage Website > Advance Settings. Expand Connection Limits, change the Time-out value"

"On the bottom panel, open Configuration Editor. In the top of Editor choose system.web/httpRuntime. Find option "executionTimeout" and set new value"

And I still can't increase the 30 seconds timeout.

Web.config:

<system.web>
<httpRuntime targetFramework="4.5.1" executionTimeout="300"/>
</system.web>
I also modified the ISS of the service wcf to increase the response time to 5 minutes and modify the web.conf, but I don't know what to do and in google I don't see anything that can help me.
Web.config WCF:

<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="2147483647" sendTimeout="01:00:01"></binding>
<binding name="IncreasedTimeout" sendTimeout="00:25:00"></binding
</basicHttpBinding>
<wsHttpBinding>
<binding sendTimeout="00:5:00" receiveTimeout="00:5:00"> </binding> </wsHttpBinding>
</bindings>

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,346 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,246 questions
{count} votes

Accepted answer
  1. Laxmikant 216 Reputation points
    2022-11-23T11:21:23.097+00:00

    to increase timeout of WCF service request and response. Open Reference.cs file from MVC application, you will see

    GetBindingForEndpoint update this method as per your required values.

    if ((endpointConfiguration == EndpointConfiguration.BasicHttpBinding_IYourService))  
                {  
                    System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();  
                    result.MaxBufferSize = int.MaxValue;  
                    result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;  
                    result.MaxReceivedMessageSize = int.MaxValue;  
                    result.AllowCookies = true;  
                    //Here's where you can set the timeout values  
                    result.SendTimeout = new System.TimeSpan(0, 5, 0);  
                    result.ReceiveTimeout = new System.TimeSpan(0, 5, 0);  
      
                    return result;  
                }  
    
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Venkata Subba Reddy Darukumalli 1 Reputation point
    2022-11-23T11:24:44.077+00:00

    to increase timeout of WCF service request and response. Open Reference.cs file from MVC application, you will see

    GetBindingForEndpoint update this method as per your required values.

    if ((endpointConfiguration == EndpointConfiguration.BasicHttpBinding_IYourService))
    {
    System.ServiceModel.BasicHttpBinding result = new System.ServiceModel.BasicHttpBinding();
    result.MaxBufferSize = int.MaxValue;
    result.ReaderQuotas = System.Xml.XmlDictionaryReaderQuotas.Max;
    result.MaxReceivedMessageSize = int.MaxValue;
    result.AllowCookies = true;
    //Here's where you can set the timeout values
    result.SendTimeout = new System.TimeSpan(0, 5, 0);
    result.ReceiveTimeout = new System.TimeSpan(0, 5, 0);

                 return result;  
             }
    
    0 comments No comments