Search code examples
c#asp.netteleriktelerik-gridwindows-server-2012-r2

RadGrid BIFF Export - An existing connection was forcibly closed by the remote host


I'm running Windows Server 2012 R2, just upgraded from Windows 2008.

I have a Telerik grid with images. I recently changed servers, and now I can't export the grid to biff with the images. The error is as follows:

An existing connection was forcibly closed by the remote host

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) +249

[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) +8420333
   System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count) +57
   System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest) +243
   System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest) +470
   System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest) +8552078
   System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult) +230
   System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) +645
   System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) +9
   System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) +87
   System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result) +1467
   System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size) +84
   System.Net.ConnectStream.WriteHeaders(Boolean async) +816

[WebException: The underlying connection was closed: An unexpected error occurred on a send.]
   System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request) +3407972
   System.Net.WebClient.DownloadData(Uri address) +214
   Telerik.Web.UI.ExportInfrastructure.Image.GetImageFromUrl() +226
   Telerik.Web.UI.ExportInfrastructure.XlsBiffRenderer.CreateWorksheet(Table tbl, Workbook wb) +2238
   Telerik.Web.UI.ExportInfrastructure.XlsBiffRenderer.Render() +198
   Telerik.Web.UI.Grid.Export.TableViewExporter.ExcelExportRenderForm(HtmlTextWriter nullWriter, Control form) +1057
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +131
   System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +151
   System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +49
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +131
   System.Web.UI.Page.Render(HtmlTextWriter writer) +40
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5363

This is a dynamically created grid, and it used to work on the old server.

I have narrowed it down to the following code for sure. When I include the full URL (which is an ashx that generates the image), it fails. When I exclude the "https://www.someserver.com", it works fine, but does not export the image in BIFF.

GridImageColumn gci = new GridImageColumn();
    gridPreview.MasterTableView.Columns.Add(gci);
    gci.HeaderText = fieldName;
    gci.UniqueName = fieldName.Replace(" ", string.Empty);
    gci.FooterText = "image";
    gci.DataImageUrlFormatString = string.Format("https://www.someserver.com/{0}{{0}}/w100/h100", cm.SiteInfo.FriendlyName);
    gci.DataImageUrlFields = new string[] { fieldName };
    gci.ImageWidth = 100;
    gci.ItemStyle.Width = 100;
    gci.HeaderStyle.Width = 100;
    gci.AllowFiltering = false;

I've been spending an entire day pulling my hair out on this one, and I need a quick answer to solve this problem... Is there a server setting in IIS 8 I need to keep the callbacks to the image from failing? Is it a permissions issue that when the code calls the generated image it doesn't have access to the image (sounds ridiculous, but I'm grasping at straws now).

I have tried increasing the timeout (which I suspected wouldn't help, as it fails pretty quick). I ran through a debug session, and it crashes right on prerender. Digging into Telerik using JustDecompile, I find that it does its work on prerender, but I think I'm chasing my tail for something I'm missing. After all, if it works on one server, it should work on the one I moved it to?

It works great on a standard Excel export, but of course, images don't get embedded.

Edit: I reactivated the old server using the old database (with the images still pulling from the new server), and it fails for the same thing. That rules out everything, except for the way that Telerik pulls the images from the new server. I may go back, edit everything including the images to see if the error changes.

Edit Again: Well, I changed everything back on the old server, and the one thing that stopped the error was changing the image URL to local URLs on the old server. SO - this means that absolutely has something to do with grabbing the images on the new server. Soooo - what's the difference? Is it the DDOS protection? Is it the permissions? (edit: No it's not - I used a firehose "everyone" read/write, and same issue) This is driving me insane.


Solution

  • As it turned out, this was a bug in the 2015 code. With the release of Q1/2016 of Telerik Tools, this appears to be resolved. After update, I can now export in SSL.