X-Dev
X-Dev

Reputation: 475

web request with HTTPS/TLS causes timeout

I'm sending out a basic request to a 3rd party web service, but it always times out on machines with .net v4.0 installed. (timeout exception: "The operation has timed out")

It works fine if 4.5 is installed but we need to support 4.0

The service host has disabled support for SSL3 protocol so the following will not work for me.

ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;

the code for sending the request is basic

var request = ((HttpWebRequest)WebRequest.Create("https://hostname.com"));             
var response = (HttpWebResponse)request.GetResponse(); //timeout here

This also does not help as it never reaches this point

ServicePointManager.ServerCertificateValidationCallback = (sender,certificate,chain,sslPolicyErrors)=> true;

The 3rd party web service works fine if I just navigate to it using a web browser.

Extending the timeout values will obviously not work in this case as the 3rd party sever never actually returns a response.

What can I do to resolve this issue?

update: the issue was occurring on win7 and win server 2003 machines. Another test was done on an XP machine with .NETv4.0. the test passed and a response was received. So .NETv4.0 may not be the problem here. (but the upgrade to 4.5 did resolve the issue previously.)

The issue must be environmental. What can I do to troubleshoot this issue?

Upvotes: 1

Views: 3156

Answers (2)

X-Dev
X-Dev

Reputation: 475

Answer by dotwilbert found here

The .NET framework on Windows 7 implements a TLS extension: Server Name Indication (RFC4366). According to your post What does this TLS Alert mean the server is responding with "Unrecognized Name". Not sure why the connection is reported to time out, because it really doesn't. Your network traces should show that the client initiates a connection termination after this [FIN,ACK]. Downgrading to SSL3 avoids the invocation of the the SNI.

FYI: The same .NET framework on Windows XP does not use the TLS Server Name Indication Extension. Your program will work there....

In my case I traced the occurrence of this to a missing ServerName directive in Apache. Adding the ServerName to the SSL configuration solved it, because now the web server no longer is unaware of its name.

3rd party updated the SSL config to include the ServerName and issue was resolved.

Upvotes: 1

rakeshdas
rakeshdas

Reputation: 2533

You can probably use the HttpWebRequest.Timeout, and with that property, it has two parameter to set your timeout wait time.

Upvotes: 0

Related Questions