title: ASP.NET / SSAS / SQL Server - An existing connection was forcibly closed by the remote host
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/125096/can-i-turn-off-impersonation-just-in-a-couple-instances">Can I turn off impersonation just in a couple instances</a>  </p>
  </blockquote>
  
  
  
  <p>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:</p>
  
  <pre><code>System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
  </code></pre>
  
  <p><strong>Here is my connection string:</strong></p>
  
  <pre><code>AdomdConnection conn = new AdomdConnection("Data Source=BTN-SQL1;Initial Catalog=BTNTurboAnalysisServices;");
  </code></pre>
  
  <p>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.</p>
  
  <p><strong>Below is my stack trace:</strong></p>
  
  <pre><code>[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 &lt;path to file&gt;/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.&lt;&gt;c__DisplayClass15.&lt;InvokeActionMethodWithFilters&gt;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.&lt;&gt;c__DisplayClassb.&lt;BeginProcessRequest&gt;b__5() +62
     System.Web.Mvc.Async.&lt;&gt;c__DisplayClass1.&lt;MakeVoidDelegate&gt;b__0() +20
     System.Web.Mvc.&lt;&gt;c__DisplayClasse.&lt;EndProcessRequest&gt;b__d() +54
     System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +469
     System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +375
  </code></pre>
  
  <p>Any help would be appreciated, thanks!</p>