Solved

CommunicationException when sending a file through WCF

Posted on 2010-09-22
4
1,785 Views
Last Modified: 2012-05-10
Hi!

On one of my WCF service, I can send file(in an array of bytes). I noticed this is working with small files, but once I've bigger file(my test is with a 400kB file), I'm running into this exception, throwed client side:


System.ServiceModel.CommunicationException was unhandled
  Message=The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.9980138'.
  Source=mscorlib
  StackTrace:
    Server stack trace:
       at System.ServiceModel.Channels.StreamConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
       at System.ServiceModel.Channels.StreamConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout, BufferManager bufferManager)
       at System.ServiceModel.Channels.FramingDuplexSessionChannel.OnSend(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.OutputChannel.Send(Message message, TimeSpan timeout)
       at System.ServiceModel.Dispatcher.DuplexChannelBinder.Request(Message message, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
       at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
       at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
       at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    Exception rethrown at [0]:
       at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
       at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
       at Infoteam.GfK.Communication.WCF.IFileService.SaveFile(IAuthInformation authInfos, File File)
       at WcfTester.Program.Main(String[] args) in D:\Workspace\10067 Gfk Telecontrol AG, TOM-TAS\GFK_TOM-TAS.root\GFK_TOM-TAS\WcfTester\Program.cs:line 87
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.IO.IOException
       Message=The write operation failed, see inner exception.
       Source=System
       StackTrace:
            at System.Net.Security.NegotiateStream.ProcessWrite(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
            at System.Net.Security.NegotiateStream.Write(Byte[] buffer, Int32 offset, Int32 count)
            at System.ServiceModel.Channels.StreamConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
       InnerException: System.ServiceModel.CommunicationException
            Message=The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:00:59.9980138'.
            Source=System.ServiceModel
            StackTrace:
                 at System.ServiceModel.Channels.SocketConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
                 at System.ServiceModel.Channels.BufferedConnection.WriteNow(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, BufferManager bufferManager)
                 at System.ServiceModel.Channels.BufferedConnection.WriteNow(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
                 at System.ServiceModel.Channels.BufferedConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
                 at System.ServiceModel.Channels.ConnectionStream.Write(Byte[] buffer, Int32 offset, Int32 count)
                 at System.Net.Security.NegotiateStream.StartWriting(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
                 at System.Net.Security.NegotiateStream.ProcessWrite(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
            InnerException: System.Net.Sockets.SocketException
                 Message=Une connexion établie a été abandonnée par un logiciel de votre ordinateur hôte
                 Source=System
                 ErrorCode=10053
                 NativeErrorCode=10053
                 StackTrace:
                      at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
                      at System.ServiceModel.Channels.SocketConnection.Write(Byte[] buffer, Int32 offset, Int32 size, Boolean immediate, TimeSpan timeout)
                 InnerException:







The strange thing is that the error comes something like only one half second after the call has been done.
0
Comment
Question by:Nargzul
  • 2
4 Comments
 
LVL 18

Expert Comment

by:DarrenD
ID: 33741707
Hi,

What binding are you using?

Can you post you web.config file?

Cheers,

Darren
0
 
LVL 1

Accepted Solution

by:
Nargzul earned 0 total points
ID: 33741720
I resolved my problem by doing this:


                NetTcpBinding binding = new NetTcpBinding();
                binding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
                binding.ReaderQuotas.MaxArrayLength = int.MaxValue;
                binding.MaxBufferSize = int.MaxValue;
                binding.MaxReceivedMessageSize = int.MaxValue;
                binding.CloseTimeout = DateTime.Now.AddMinutes(30) - DateTime.Now;
                binding.OpenTimeout = DateTime.Now.AddMinutes(30) - DateTime.Now;
                binding.ReceiveTimeout = DateTime.Now.AddMinutes(30) - DateTime.Now;
                binding.SendTimeout = DateTime.Now.AddMinutes(30) - DateTime.Now;
0
 
LVL 1

Expert Comment

by:rafaelrgl
ID: 33979810
Same problem here, is this config on the application side or on the wcf side?
0
 
LVL 1

Author Comment

by:Nargzul
ID: 33980355
I've done this on two side, because it affects only data the side SEND, so if you want to have these parameter on two ways, you've to specify them on two side.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question