2
Vote

HDInsightClient > 1.3.0.1 not working in Web Application

description

(possibly related to issue reported in: https://hadoopsdk.codeplex.com/discussions/562447 )

Using HDInsight .NET client >= 1.3.0.1 in a web application (ASP.NET MVC 5) causes operations on the HDInsightClient object to never return. eg:
            var client = HDInsightClient.Connect(new HDInsightAccessTokenCredential(Guid.Parse("eb1a85f8-09c6-4c54-ba20-5a6f264744c8"), "eyJ0eXAiOi..."));
            // Next call (or any call on the client object) never returns
            var locations = client.ListAvailableLocations();
The issue is reproducible using library version >= 1.3.0.1 and consistently does NOT appear in versions prior to that. I have also confirmed that the authentication method (certificate or bearer token) does not affect this behavior. The call consistently works correctly in any environment other than a web application.

From a Fiddler trace, I can see that the request is issued to https://management.core.windows.net:8443/eb1a85f8-09c6-4c54-ba20-5a6f264744c8/resourceproviders/hdinsight/Properties?resourceType=containers. The host; https://management.core.windows.net:8443 asks for a client certificate during the TLS negotiation, but even if no certificate is used a valid response is received. The response does not seem to be processed by the HDInsightClient library and therefore the call never returns.

comments

Lesmian wrote Oct 30, 2014 at 9:50 PM

Same issue here. I tried different project from classic ASP, Azure Websites and Console App and HDInsight .NET SDK works only on console app. Like jamesbak I checked response in fiddler and it looks good, but still website hangs after call to client method (it never returns). I checked different certificates from Azure Public Profile to self-signed and all works well on console and don't work on website project. Whats more confusing is that i checked website management api with the same certificate as in hd insight api and it works well on website project.

dmitriychernenko wrote Dec 5, 2014 at 4:24 PM

I've faced with the same problem, you can use simple workaround, just wrap all hdinsight calls into Task.Run(...).Result for synchronous calls and await Task.Run(...) for asynchronous, like this:
var locations = Task.Run(() => client.ListAvailableLocations()).Result;

rhizohm wrote Jan 23, 2015 at 9:16 PM

@dmitriychernenko - THANK YOU! This problem has plagued me for a long time and I tried all kinds of different signatures that didn't solve the problem -- which I believe is a fundamental problem in the SDK with how the async and await patterns are implemented. There nested callbacks and it results in a deadlock, but your workaround contains the background threads so they don't lose affinity.