3

Possible Duplicate:
Can I turn off impersonation just in a couple instances

I've created an application that, when uploaded to my server throws an exception. It works fine locally but the moment I upload it to my server I get the following error:

System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host

Here is my connection string:

AdomdConnection conn = new AdomdConnection("Data Source=BTN-SQL1;Initial Catalog=BTNTurboAnalysisServices;");

Its worth noting that BTN-SQL1 is on a different server to my web server, could that be causing a problem? I'm also using Windows Authentication.

Below is my stack trace:

[SocketException (0x2746): An existing connection was forcibly closed by the remote host]
   System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +245

[IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.]
   System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size) +7856541
   System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count) +253
   Microsoft.AnalysisServices.AdomdClient.DimeRecord.ForceRead(Stream stream, Byte[] buffer, Int32 length) +61
   Microsoft.AnalysisServices.AdomdClient.DimeRecord.ReadHeader() +53
   Microsoft.AnalysisServices.AdomdClient.DimeReader.ReadRecord() +112
   Microsoft.AnalysisServices.AdomdClient.TcpStream.GetResponseDataType() +120

[AdomdConnectionException: The connection either timed out or was lost.]
   Microsoft.AnalysisServices.AdomdClient.XmlaClient.EndRequest() +1367
   Microsoft.AnalysisServices.AdomdClient.XmlaClient.CreateSession(ListDictionary properties, Boolean sendNamespaceCompatibility) +387
   Microsoft.AnalysisServices.AdomdClient.XmlaClientProvider.Microsoft.AnalysisServices.AdomdClient.AdomdConnection.IXmlaClientProviderEx.CreateSession(Boolean sendNamespaceCompatibility) +148
   Microsoft.AnalysisServices.AdomdClient.AdomdConnection.ConnectToXMLA(Boolean createSession, Boolean isHTTP) +235
   Microsoft.AnalysisServices.AdomdClient.AdomdConnection.Open() +973
   btn_intranet.Areas.Sales.Controllers.HomeController.CumulativeChart(String month, String year) in <path to file>/HomeController.cs:52
   lambda_method(Closure , ControllerBase , Object[] ) +182
   System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +264
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +39
   System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +129
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +798650
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +314
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +798704
   System.Web.Mvc.Controller.ExecuteCore() +159
   System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) +335
   System.Web.Mvc.<>c__DisplayClassb.<BeginProcessRequest>b__5() +62
   System.Web.Mvc.Async.<>c__DisplayClass1.<MakeVoidDelegate>b__0() +20
   System.Web.Mvc.<>c__DisplayClasse.<EndProcessRequest>b__d() +54
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375

Any help would be appreciated, thanks!

Community
  • 1
  • 1
CallumVass
  • 11,288
  • 26
  • 84
  • 154

3 Answers3

0

It looks like you're accessing via MVC, so does your IIS application pool identity have permissions to access the SSAS instance? You may need to create a windows (Ideally domain) account, and get the application pool to run under that, giving it permissions to access SSAS.

Meff
  • 5,889
  • 27
  • 36
  • I've noticed the application pool for my project on IIS has an identity of network service. So if I then configure my SSAS instance to allow network service identity, would that work? – CallumVass Oct 21 '11 at 10:52
  • I'm not 100% sure you can allow network service, but if you can that should do it. You've probably fixed this by now, given the week that's gone by...? – Meff Oct 27 '11 at 10:54
  • No, I actually havent. I've just moved onto different things. This has me stumped because it works fine locally so I don't think its my connection string? – CallumVass Oct 28 '11 at 07:36
  • @BiffBaffBoff If it's not permissions - Looking at your error more closely, is it a 30 second timeout issue? Trace the MDX in SQL Server Profiler, how quickly does it complete? – Meff Oct 28 '11 at 10:32
  • Surely that would fail locally as well then? But the fact that it doesnt, must mean a permission issue from IIS > SSAS. I'll try and play around in IIS and see if I can get it to work – CallumVass Oct 28 '11 at 10:40
  • @BiffBaffBoff I meant that the query may run fine locally on your test cube, but timeout in production if there's lots more data? – Meff Oct 28 '11 at 10:47
  • If the SQL Server Profiler trace shows no login or query execution then we're back to looking at permissions. You say they're on different boxes (IIS & SSAS) are they on the same Windows domain? – Meff Oct 28 '11 at 10:48
  • Yeah they're on the same Domain – CallumVass Oct 28 '11 at 11:03
  • OK so try the profiler trace against SSAS, see what happens when you run the page that runs the cumulative chart query - If it runs and times out, permissions are fine. If it doesn't run, create the domain user, get the relevant IIS app pool to run as that user, and give that user permissions on the cube. – Meff Oct 28 '11 at 11:13
  • My app now runs as a specific user now and i've given that user permission to access the SSAS, what do I specify in my connection string because I still get the same error :/ – CallumVass Oct 31 '11 at 12:26
  • @BiffBaffBoff if your IIS Application Pool is running as that user, then you shouldn't need anything else in your connection string, as Windows auth will come from the app pool identity. Have you logged in as that user and made sure you can browse the cube via management studio? Can that user run the MDX you want to run via MGMT studio? – Meff Oct 31 '11 at 13:09
  • @BiffBaffBoff are you running a profiler trace against SSAS while you try and do this? Does it show failed login? Query timeout? – Meff Oct 31 '11 at 13:19
  • Its me again, sorry for the late answer: I ran the profiler trace as my IIS identity and it tried to connect to the SSAS as an anonymous user :/ – CallumVass Nov 04 '11 at 12:09
  • Some more information: I disabled IIS impersonation and it worked, so its not even using my IIS identity when communicating with the SSAS. Therefore I believe its a double-hop issue, i've tried setting Kerberos in the connection string but I get an error still. – CallumVass Nov 04 '11 at 12:22
  • I need to have impersonation enabled, so disabling it isnt an option. – CallumVass Nov 04 '11 at 12:31
  • The error is: [Win32Exception (0x80004005): No credentials are available in the security package] and [AdomdConnectionException: Authentication failed.] – CallumVass Nov 04 '11 at 12:38
  • I've asked a new question which can be found here as its a different issue/exception to this: http://stackoverflow.com/questions/8009198/kerberos-double-hop-issue-between-iis-and-ssas – CallumVass Nov 04 '11 at 12:51
0

I would recommend verifying that the firewall on the SQL Server machine doesn't block your request.

Wiktor Zychla
  • 47,367
  • 6
  • 74
  • 106
0

I've managed to solve the problem. Basically I just disabled impersonation for the specific methods that were causing the problem by using the solution found here:

Can I turn off impersonation just in a couple instances

Community
  • 1
  • 1
CallumVass
  • 11,288
  • 26
  • 84
  • 154
  • I had the same problem (Windows Server 2008 R2). I solved it by creating new Application Pool and changed Identity property to account that has rights to read the cube. – ilija veselica Jan 19 '12 at 09:11