HttpWebRequest timeout on alpha

Hi,

I am using the C# method below to get JSON data from a Jboss Application server

Method is used in Eikon WebApp under file WebCAllableFunctions.cs

public string GetEsJson(string query, string body, IAppServerServices services)
{
string json = null;

HttpWebRequest request = (HttpWebRequest)WebRequest.Create(body);
request.Timeout = 600000;
try
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
response.Close();
HttpStatusCode statusCode = response.StatusCode;
if (HttpStatusCode.OK.Equals(statusCode))
{
using (responseStream)
{
StreamReader reader = new StreamReader(responseStream, Encoding.UTF8);
json = reader.ReadToEnd();
}
}

}
catch (WebException ex)
{
System.Diagnostics.Debug.WriteLine(ex);
}

return json;
}

The above HttpWebRequest is timing out on Alpha, the same request is working fine locally

I tried to increase the timeout (request.Timeout = 600000) but it doesn't seem to have any impact, the request is always timing out after 40 seconds

Any help appreciated

Thanks

Answers

  • We need a little more information in terms of whether this piece of code is calling the same server from both Alpha and your workstation; but for the sake of expediency, let's assume it is. The fact that you are getting a connection timeout, implies that there's either a routing issue or a firewall from Alpha to your JBoss endpoint. I will exclude Proxy issues since you haven't mentioned you are using one. If I where to choose between routing and firewall, I would be going for the firewall issue first, then look at routing. On a separate note: Instead of treating JSON as a String, try using `Windows.Data.Json`. It gives you access to a JsonObject and friends, which you should return, instead of a null String.
  • Both Alpha and locally are calling the same server, on Alpha if the server responds in less than 40 seconds its working fine and I get to download my response, locally it wouldn't timeout even after 40 seconds

    Thanks!
  • To me then, it seems that some network appliance between Alpha and the server is imposing a 40sec connection timeout. Bear in mind, that the .Timeout property, is for the entirety of the request, not just the stream reading part.