Timeout error in ASP.NET mvc

I am facing a weird issue, I am running Quartz jobs to fetch data from 2 different URL, but getting timeout error on one, another is working just fine. The inner exception of error that I get says 'The operation has timed out'.

One more interesting thing is that I am not getting this error on my local system, on my local, both the jobs are fetching data correctly, but on server one fails.

I also spoke to the team of the website from which I am fetching data, they told me that their configuration for both urls are same, so there is no issue at their end.

I have made some changes in my webconfig file while trying to fix this issue by reading online, but no luck yet.

I have added this line in the appSettings tag in web.config

<add key="SqlCommandTimeOut" value="10000000" />

My connection string looks like:

<add name="xyzDBEntities" connectionString="metadata=res://*/xyzDB.csdl|res://*/xyzDBEntities.ssdl|res://*/xyzDBEntities.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=SQL1234.xyzsite.com;initial catalog=xyzDB;User Id=xyzDB_admin;Password=xyzpassword;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />

It would be great if someone can help me in sorting this out. Please let me know if more details are needed. Thanks!

Answers


Extending WebClient class and overriding GetWebRequest() by setting timeout to 1 minute resolved my issue.

public class CustomWebClient : WebClient{
    protected override WebRequest GetWebRequest(Uri address){
        HttpWebRequest request = (HttpWebRequest)base.GetWebRequest(address);
        request.Timeout = 60000; //1 minute timeout
        return request;
    }
}

Need Your Help

Cannot delete file programmatically in C# with UAC and admin account

c# .net visual-studio permissions delete-file

I am working on a self-updating system for my application that compares assembly version numbers, then wipes the local directory and copies new server files over. The app has a custom manifest that

Go (Golang) - checking file extension not working in Go

file go

I want to get a file path from the console and check if the file is a vm file.