Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

CommunicationException when sending a file through WCF

Posted on 2010-09-22
4
Medium Priority
?
1,847 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

Industry Leaders: 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

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Simulator games are perfect for generating sample realistic data streams, especially for learning data analysis. It is even useful for demoing offerings such as Azure stream analytics, PowerBI etc.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

916 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