Click here to Skip to main content
15,902,939 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
Dear Experts,

I have a from that uploads files to data table(in session) and then after clicking on send button it calls a webservice dynamically and uploads the file to data base.

I've set the request length and etc for both application and webservice to 2GB:

<httpRuntime executionTimeout="10000" maxRequestLength="2000000"/>

Every thing works fine until the file size reaches to 100MB

After that, the application returns me an exception:

Exception has been thrown by the target of an invocation.
InnerException: The underlying connection was closed: An unexpected error occurred on a send.

I've a custom exception on my webservice codes so I know it will never enter the codes of webservice.

I should add that the call web service dynamically is a dll that I used.... can anybody help me?

[edit] little typo and format[/edit]
[improve] I should add that the webservice and the Prosentation are on the same server, also I've checked this with UI on my local computer to call that webservice[/improve]
[improve2]I'm using .net 3.5[/improve2]
[improve 3] this is full error text
System.Net.WebException occurred
  Message="The underlying connection was closed: An unexpected error occurred on a send."
       at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
       at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
       at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
       at NHTC.WA.DMS_Maroun.wsprojFileInsert.WSManageDMSProject.InsertFile(DataSet dsInput, String userName) in C:\NHTC_TFS_WorkSpace\OrganizationPortal\UI\DMS_Maroun\NHTC.WA.DMS_Maroun\NHTC.WA.DMS_Maroun\Web References\wsprojFileInsert\Reference.cs:line 2212
       at NHTC.WA.DMS_Maroun.iMultipleuploads_M.insertNewFiles() in C:\NHTC_TFS_WorkSpace\OrganizationPortal\UI\DMS_Maroun\NHTC.WA.DMS_Maroun\NHTC.WA.DMS_Maroun\iMultipleuploads_M.aspx.cs:line 302
  InnerException: System.IO.IOException
       Message="Unable to write data to the transport connection: An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full."
            at System.Net.Sockets.NetworkStream.MultipleWrite(BufferOffsetSize[] buffers)
            at System.Net.Connection.Write(ScatterGatherBuffers writeBuffer)
            at System.Net.ConnectStream.ResubmitWrite(ConnectStream oldStream, Boolean suppressWrite)
       InnerException: System.Net.Sockets.SocketException
            Message="An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full"
                 at System.Net.Sockets.Socket.MultipleSend(BufferOffsetSize[] buffers, SocketFlags socketFlags)
                 at System.Net.Sockets.NetworkStream.MultipleWrite(BufferOffsetSize[] buffers)
Updated 23-Apr-12 23:55pm
StM0n 24-Apr-12 4:00am    
Lookin' forward to a suitable answer... I could also run into that.

Based on the error message: "The underlying connection was closed: An unexpected error occurred on a send.", it does not looks like a failure because of file size here. It sounds more like the connection got closed in between because of the time it takes to upload. See if these help:
You receive one or more error messages ...[^]
The underlying connection was closed...[^]
Solving "The underlying connection was closed...[^]
Share this answer
ashkan sirous 24-Apr-12 5:23am    
But it only takes 1 sec to raise error and Also every thing works fine for a file with 98MB but when file size changed to 104MB it raise the error
<httpruntime executiontimeout="10000" maxrequestlength="2000000" />

Also this tag in client application which is using web service ..
Share this answer
ashkan sirous 24-Apr-12 8:45am    
I've done it on both server and webservice...
I've changed the call webservice method to normal web service calling and still the same error raised...
Share this answer
Sandeep Mewara 24-Apr-12 4:59am    
Not an answer. Just an update to your question. You should use 'Improve Question' link and post such things.
ashkan sirous 24-Apr-12 5:34am    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900