2

I have written following code and it does not work. The following error comes while uploading file to the web services:

1.An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full

2.The underlying connection was closed: An unexpected error occurred on a send.

I have used the following code for the web service and when the file size is more than 90 mb the error comes:

LocalService.IphoneService obj = new LocalService.IphoneService();
byte[] objFile = FileToByteArray(@"D:\Brijesh\My Project\WebSite5\IMG_0010.MOV");
int RtnVal = obj.AddNewProject("demo", "demo", "[email protected]", "[email protected]", 1, 2,    29, "IMG_0010.MOV", objFile,"00.00.06");

public byte[] FileToByteArray(string fileName)
{
    byte[] fileContent = null;
    System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Open, System.IO.FileAccess.Read);
    System.IO.BinaryReader binaryReader = new System.IO.BinaryReader(fs);
    long byteLength = new System.IO.FileInfo(fileName).Length;
    //byteLength = 94371840;
    fileContent = binaryReader.ReadBytes((Int32)byteLength);
    fs.Close();
    fs.Dispose();
    binaryReader.Close();
    return fileContent;
}
3
  • Post the relevant part of the code, so we can help you. Commented Aug 15, 2012 at 8:30
  • By default there's a limit on the size of the file you can upload. Have a look here for more info : msdn.microsoft.com/en-us/library/aa528822.aspx Commented Aug 15, 2012 at 8:42
  • As you given your link(vs 2008) I have install WSE 3.0 but I can not find the addin your mentioned. Wich version of WSE 3.0 did you install and where it is? Commented Aug 15, 2012 at 9:21

1 Answer 1

1

No socket will transfer 200MB in one chunk. Your will receive data in chunks mostly be between 1024 and 4096 bytes(depending on your settings).

  1. Read this data in chunks.
  2. Reassemble your file on the server.
  3. Then use this received file, assembled from bytes, as you need.

For an asp.net webservice:

enable webservice to receive large amounts of data

Increase the ASP.NET limits on the maximum size of SOAP messages and the maximum number of seconds that a request is allowed to execute by adding the configuration element to the application's web.config file. The following code example sets the ASP.NET limit on the maximum size of an incoming request to 400MB and the maximum amount of time a request is allowed to execute to 5 minutes (300 seconds).

Put this in your web.config.

<configuration>
  <system.web>
  <httpRuntime maxMessageLength="409600"
    executionTimeoutInSeconds="300"/>
  </system.web>
</configuration>

Remember you will be blocking a thread for as long this request is processed. This will not scale for a large number of users.

Sign up to request clarification or add additional context in comments.

2 Comments

I have required 200 MB file without chunks. then What I do?
Updated my answer, check. Solution was already provided in link given by Giorgio Minardi.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.