Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7062525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:36:16+00:00 2026-05-28T04:36:16+00:00

When I transfer a file about 50Mb over HTTP sometimes I get this error:

  • 0

When I transfer a file about 50Mb over HTTP sometimes I get this error:

Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.

First of all I couldn’t find any solution under http://stackoverflow.com.

Any clue what I have to improve/change?

app.config:

 <bindings>
      <basicHttpBinding>
        <binding name="BasicHttpBinding_MyDomainServicesoap" closeTimeout="00:03:00" openTimeout="00:04:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="50000000" maxBufferPoolSize="50000000" maxReceivedMessageSize="50000000" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="64" maxStringContentLength="16384" maxArrayLength="32768" maxBytesPerRead="8192" maxNameTableCharCount="16384"/>
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
            <message clientCredentialType="UserName" algorithmSuite="Default"/>
          </security>
        </binding>
        <binding name="BasicHttpBinding_MyAuthenticationDomainServicesoap" closeTimeout="00:03:00" openTimeout="00:04:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="50000000" maxBufferPoolSize="50000000" maxReceivedMessageSize="50000000" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
          <readerQuotas maxDepth="64" maxStringContentLength="16384" maxArrayLength="32768" maxBytesPerRead="8192" maxNameTableCharCount="16384"/>
          <security mode="None">
            <transport clientCredentialType="None" proxyCredentialType="None" realm=""/>
            <message clientCredentialType="UserName" algorithmSuite="Default"/>
          </security>
        </binding>
      </basicHttpBinding>
    </bindings>

code:

private void FinishWebRequest(IAsyncResult result)
        {
            // Assign values to these objects here so that they can be referenced in the finally block
            Stream remoteStream = null;
            Stream localStream = null;
            WebResponse response = null;

            try
            {
                response = request.EndGetResponse(result);

              if (response != null)
                {
                    // Once the WebResponse object has been retrieved, get the stream object associated with the response's data
                    remoteStream = response.GetResponseStream();

                    // Create the local file
                    string pathToSaveFile = Path.Combine(FileManager.GetFolderContent(), FileView.Filename);
                    localStream = File.Create(pathToSaveFile);

                    WinAPI.SYSTEM_INFO sysinfo = new WinAPI.SYSTEM_INFO();
                    WinAPI.GetSystemInfo(ref sysinfo);

                    // Allocate a buffer 
                    byte[] buffer = new byte[int.Parse(sysinfo.dwPageSize.ToString())];     
                    int bytesRead;

                    // Simple do/while loop to read from stream until no bytes are returned
                    do
                    {
                        // Read data (up to 1k) from the stream
                        bytesRead = remoteStream.Read(buffer, 0, buffer.Length);

                        // Write the data to the local file
                        localStream.Write(buffer, 0, bytesRead);

                        // Increment total bytes processed
                        BytesProcessed += bytesRead;
                    } while (bytesRead > 0);

                    FileView.Downloaded = DateTime.Now;

                    if (BytesProcessed > 0)
                    {
                        FileView.IsSuccess = true;
                        FileView.IsDownloading = false;
                    }
                    else
                    {
                        FileView.IsSuccess = false;
                        FileView.IsDownloading = false;
                    }
                } 
            }
            catch (Exception ex)
            {
                #region Error
                LogEntry l = new LogEntry();
                l.Message = string.Format("{0}", ex.Message);
                l.Title = "FinishWebRequest() Error";
                l.Categories.Add(Category.General);
                l.Priority = Priority.Highest;

                if (ex.InnerException != null) l.ExtendedProperties.Add("InnerException", ex.InnerException.Message);

                CustomLogger.CustomLogger.WriteErrorLog(l);
                #endregion
            }
            finally
            {
                // Close the response and streams objects here to make sure they're closed even if an exception is thrown at some point
                if (response != null) response.Close();
                if (remoteStream != null) remoteStream.Close();
                if (localStream != null) localStream.Close();
            }
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:36:17+00:00Added an answer on May 28, 2026 at 4:36 am

    I am not sure if it is a solution for all cases.

    But when I reduced the number of parallel connections to the server to download big files from 3 to 2 only there are no error.

    (Early I used 3 parallel connections.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my WCF service, when trying transfer large data I constantly get an error:
Jeff Atwood talked about doing an ISP-to-ISP file transfer: http://friendfeed.com/e/63fb9e72-6cd5-a8ac-88dc-02ce720033f9/wow-just-did-an-isp-to-isp-file-transfer-650mb-in/ What is this? I
Suppose I want to transfer just a portion of a file over FTP -
Hello every one I want to ask a question about file transfer using sockets.
Hi im thinking about developing a sort of File Transfer program and was wondering
I have this home work where I have to transfer a very big file
I want to transfer a file from 1 php server (A) to another php
i need to transfer a file of 8.3MB over TCP, when i use file
noob here, I'm trying to transfer a file using rsync from windows to linux.
I need to extract the text from a PDF file. This text will likely

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.