CommunicationObjectAbortedException

This is an error I receive while returning an object over a service (net.Tcp binding). The object is an LLBLGenPro EntityCollection. The EntityCollection contains EmployeeEntities. I can successfully return such a collection if the size of the collection is smaller than about 20 entries. But if it is any bigger I get the following error:


An error occurred while transmitting data.
System.IO.IOException: The read operation failed, see inner exception. ---> System.ServiceModel.CommunicationObjectAbortedException: 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. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.ServiceModel.Channels.SocketConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
--- End of inner exception stack trace ---
at System.ServiceModel.Channels.SocketConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
at System.ServiceModel.Channels.DelegatingConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
at System.ServiceModel.Channels.ConnectionStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
at System.Net.Security.NegotiateStream.StartFrameHeader(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.NegotiateStream.StartReading(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.NegotiateStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
--- End of inner exception stack trace ---
at System.Net.Security.NegotiateStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.NegotiateStream.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.ServiceModel.Channels.StreamConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)


Is there a setting I need to specify in my config file to allow for larger objects Do I need to stream this (doesn't seem like it is that big).


Answer this question

CommunicationObjectAbortedException

  • Ian Smith

    Yeah, it's a message size issue. I increased the MaxMessageSize and the data comes through.

    I had to do some thinking about how I wanted things to travel over the wire. The message size makes sense to prevent DoS attacks, obviously. What I was returning was a collection of items that was the result of a search query. The size of the collection was unknown at runtime. What I wasn't doing is limiting the scope of the query - something I should know better about.

    Once I limit the max returned results I should be able to get a better idea of what my maximum message size is going to be and set the config limits properly.

  • shellback

    I have exactly the same problem and in may case, too, it seems that the MaxMessageSize property is not considered

    I tried to change it also on the server side but without success

    My client config is

    <configuration>

    <system.serviceModel>

    <client>

    <endpoint

    address="net.tcp://localhost:8080/NetTcpBinding"

    binding="netTcpBinding"

    name="NetTcpBinding"

    contract="IInstruments" />

    <endpoint

    address="http://localhost:8081/BasicHttpBinding"

    binding="basicHttpBinding"

    name="BasicHttpBinding"

    contract="IInstruments" />

    <endpoint

    address="net.tcp://localhost:8082/NetTcpBinding"

    binding="netTcpBinding"

    name="NetTcpBinding"

    contract="IOrders" />

    <endpoint

    address="http://localhost:8083/BasicHttpBinding"

    binding="basicHttpBinding"

    name="BasicHttpBinding"

    contract="IOrders" />

    </client>

    <bindings>

    <wsDualHttpBinding>

    <binding name="noSecurity">

    <security mode="None"></security>

    </binding>

    </wsDualHttpBinding>

    <wsHttpBinding>

    <binding name="noSecurity">

    <security mode="None"></security>

    </binding>

    </wsHttpBinding>

    <netTcpBinding>

    <binding name="netTcpBinding" maxMessageSize="2147483648"></binding>

    </netTcpBinding>

    </bindings>

    </system.serviceModel>

    </configuration>

    and the server config is

    <configuration>

    <system.serviceModel>

    <services>

    <service type="InternalMarket.Instruments">

    <endpoint

    address="NetTcpBinding"

    binding="netTcpBinding"

    contract="InternalMarket.IInstruments"/>

    <endpoint

    address="BasicHttpBinding"

    binding="basicHttpBinding"

    contract="InternalMarket.IInstruments"/>

    </service>

    <service type="InternalMarket.Orders">

    <endpoint

    address="NetTcpBinding"

    binding="netTcpBinding"

    contract="InternalMarket.IOrders"/>

    <endpoint

    address="BasicHttpBinding"

    binding="basicHttpBinding"

    contract="InternalMarket.IOrders"/>

    </service>

    </services>

    <bindings>

    <netTcpBinding>

    <binding name="MLSServiceBinding" maxMessageSize="2147483648">

    <security mode="Message">

    <message clientCredentialType="UserName" defaultProtectionLevel="EncryptAndSign" />

    </security>

    </binding>

    </netTcpBinding>

    </bindings>

    <behaviors>

    <behavior name="MLSServiceBehavior" returnUnknownExceptionsAsFaults="True">

    <metadataPublishing enableGetWsdl="true" />

    <serviceAuthorization principalPermissionMode="None" />

    </behavior>

    </behaviors>

    </system.serviceModel>

    </configuration>

    What's wrong

    Please, I need some help!


  • apbradley

    you can set openTimeout,receiveTimeout,sendTimeout values on any binding

    You can open config in svcconfigeditor and change these valuse from svcconfigeditor also.

    in following config,i changed all time out values to 12 mins,if you still see the problem,you can enable trace to debug the problem

    EXAMPLE:

    < xml version="1.0" encoding="utf-8" >

    <configuration>

    <appSettings>

    <add key="baseAddress" value="http://localhost:8000/echo" />

    </appSettings>

    <system.serviceModel>

    <bindings>

    <wsHttpBinding>

    <binding name="ServiceBinding" openTimeout="00:12:00" receiveTimeout="00:12:00"

    sendTimeout="00:12:00">

    <security mode="None" />

    </binding>

    </wsHttpBinding>

    </bindings>

    <services>

    <service name="Microsoft.ServiceModel.Samples.EchoService">

    <endpoint address="http://localhost:8000/services/soap12/text"

    binding="wsHttpBinding" bindingConfiguration="ServiceBinding"

    contract="Microsoft.ServiceModel.Samples.IEchoService" listenUri="http://localhost:8000/echo/service" />

    </service>

    </services>

    </system.serviceModel>

    </configuration>

    How to enable Trace

    If you have simple service,open the config file in svcconfigeditor,from wizard,you can enable tracing and logging

    http://windowssdk.msdn.microsoft.com/library/en-us/wcf_tools/html/2db21a57-5f64-426f-89df-fb0dc2d2def5.asp frame=true

    once you have log file,you can open client side trace and service side trace file in svctraceviewer and you can filter trace by different categories

    http://windowssdk.msdn.microsoft.com/library/default.asp url=/library/en-us/WCF_tools/html/9027efd3-df8d-47ed-8bcd-f53d55ed803c.asp

    Tracing and Logging Sample

    http://windowssdk.msdn.microsoft.com/library/en-us/WCF_samples/html/a4f39bfc-3c5e-4d51-a312-71c5c3ce0afd.asp frame=true

    http://windowssdk.msdn.microsoft.com/library/en-us/WCF_samples/html/4c4058ae-17ca-4994-80f5-1a8b51840754.asp frame=true



  • narva

    I have the exact same experience as jfkrueger and clr77. I have been using the January Beta 2 build (Go-Live License version) on both basicHttpBinding and wsHttpBinding. Small datasets get returned ok from the web service but when they reach 30-50 records I get the exception.

    Setting maxMessageSize below the default of 64K on both ends gives me the appropriate error message but increasing it above 64K does not seem to have any effect.

    I have tried this both on the built-in server is VS 2005 and on W2K3/IIS6 with the same results.

    I have an ASP.NET application (the client in my case) calling the web service (the server). The dataset is filled with a TableAdapter hosted in a DLL. When I access the dataset directly in the DLL from the ASP.NET application everything works fine so I think the dataset is OK.

    Does anyone have experience with medium sized datasets in the February CTP

    In my case this is a show-stopper problem that will force me back to ASMX based web services if no solution can be found.

    Previously I have worked with fairly large datasets in ASMX without any problems.


  • ukgy

    It's possible that you're running into MaxMessageSize on the server. If that's the case, you should see an error logged in the server-side traces.




  • Krishna Sunkammurali

    I am also seeing the same error although it never happens on my development machine, it only happens on test user machines that do not have VS installed. As far as I can tell it does not always matter about the size of the data being returned. The only thing that seems different for these users is that they are connecting over the WAN and I am on the LAN. Is there a way to increase the timeout

    Christian


  • Dhatri

    I am getting this same error but as far as I can tell it is not a MaxMessageSize issue. I am returning a DataSet from a WCF Service with NetTCPBindings and I am able to return smaller DataSets just fine (100 rows or so), but when they get bigger i receive this error. When I change the MaxMessageSize attribute in the Client app.config, it doesn't seem to help. I put it way higher than it needed to be and still got this error. Also, when I change my MaxMessageSize to be "5", I actually get a MaxMessageSize error, which indicates that this error is not neccessarily caused by the MaxMessageSize being too small. Anyone else having these problems or that can help me
  • CommunicationObjectAbortedException