zhejiushizhuce / protobuf-net

Automatically exported from code.google.com/p/protobuf-net
0 stars 0 forks source link

MaxItemsInObjectGraph error on wcf server logs #148

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Please include an e-mail address if this might need a dialogue!

I set up a WCF server with  one operation
[OperationContract,ProtoBehaivior]
Person GetPersons()

if GetPersons return under 9000 items everything works fine,over I got in wcf 
trace this exception Maximum numbers of items that can be serialized in a 
object graph is 65536 ...increase MaxItemsInObjectGraph

on client side I used like this
var binding=new NetTcpBinding
{
  ReaderQuotas=
  {MaxArrayLenght=int.MaxValue
  ,MaxTableCharCount=int.MaxValue
  ,MaxStringContentLenght=int.MaxValue
  ,MaxDepth=int.maxValue
  }
  ,
  MaxReceivedBufferSize=int.maxValue,
  ,MaxBufferSize=int.MaxValue
  ,MaxBufferPoolSize=int.MaxValue
};
var endpoint=new EndpointAddress("net.tcp://localhost:10000/PM/";
var channelFactory=new 
ChannelFactory<ServiceReference1.IPMChannel>(binding,enpoint);
foreach(var op in channelFactory.Endpoint.Contract.Operations)
{
var dcb=op.Behaiviors[typeof(DataContractSerializeOperationBehaivior)] as 
DataContractSerializeOperationBehaivior
if(dcb!=null) dcb.MaxItemsInObjectGraph=int.MaxValue;
}
var channnel=channelFactory.CreateChannel();
//here an error appear if we have more than 9000 persons
var persons=channel.GetPersons();

on server configuration I have this 
<behaivior name ="protoEndpointBehaivior">
<protobuf />
</behaivior >

protobuf seems to not have any properties that I can set in order to fix 
MaxItemsInObjectGraph error,so I'm stuck :(

I use the   protobuf-net-VS10.msi version on windows 7 profesional

Thank you for your work
Best regards, 
Ciprian 
int29h@gmail.com

Original issue reported on code.google.com by int...@gmail.com on 9 Jan 2011 at 11:27

GoogleCodeExporter commented 9 years ago
That is very odd - I'll have to try and repro, as this is very bizarre. Do you 
perhaps have an existing complete demo Project for this ?

Original comment by marc.gravell on 9 Jan 2011 at 11:48

GoogleCodeExporter commented 9 years ago
Any update on this? This is holding us from migrating to protobuf-net as we 
always set maxItemsInObjectGraph="2147483647". Is there an attribute like that 
in protobuf-net?

Many thanks in advance

Original comment by mike...@gmail.com on 10 Feb 2011 at 10:28

GoogleCodeExporter commented 9 years ago
That error is coming from WCF, not protobuf-net ; I do not have a repro - if 
there is anything you can show to help me repro, that would help...

Original comment by marc.gravell on 10 Feb 2011 at 11:15

GoogleCodeExporter commented 9 years ago
I have the same problem. We want to use protobuf along with 
DataContractSerializer. As far as I can see the problem is that 
ProtoEndpointBehavior replaces the DataContractSerializerOperationBehavior by 
ProtoOperationBehavior within ApplyDispatchBehavior which is invoked during 
host.Open(). In our case we set the MaxItemsInObjectGraph property of any 
DataContractSerializerOperationBehavior to a higher value. This is done before 
host.Open() gets invoked, of course. So we end up changing all opBehaviors 
before starting and on startup all those behaviors get replaced by your 
ProtoEndpointBehavior. Too bad ProtoOperationBehavior is internal :(

Not sure if this matters but we don't use configuration files. All wcf settings 
are done within code.

Original comment by roberto....@qoniac.com on 11 Feb 2011 at 3:44

GoogleCodeExporter commented 9 years ago
I have temporary fixed this problem with a copy of ProtoOperationBehavior and 
XmlProtoSerializer<T> in my project. I repaced the 
DataContractSerializerOperationBehaviors on my own (and changed MaxItems... on 
the new behaviors) and removed the ProtoEndpointBehavior. This basically solved 
the issue.

Original comment by roberto....@qoniac.com on 11 Feb 2011 at 4:02

GoogleCodeExporter commented 9 years ago
I am having the exact same issue. I am also doing the same thing roberto was 
doing (config wcf client in code and changing each opbehaviors to apply a 
larger MaxItemsInObjectGraph). That value is lost after using 
ProtoEndpoingBehavior.

Original comment by dep...@gmail.com on 16 Apr 2011 at 3:01

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I too am experiencing the same issue. 

In the meantime, I've been using this workaround which will hopefully help 
someone else.  Basically, I just made a wrapper that has as properties the 
arrays that I am trying to serve:

[ProtoContract]
    public class MyClass
    {
        [ProtoMember(1)]
        public MyObject[] MyObjects { get; set; }
    }

That seemed to allow me to bypass the MaxItemsInObjectGraph limitation.  Hope 
it helps someone.

Original comment by dlee33...@gmail.com on 31 Jan 2012 at 8:39

GoogleCodeExporter commented 9 years ago
@dlee33777 - can I clarify; what was in the *original* contract? was it a 
`MyObject[]` directly?

Original comment by marc.gravell on 31 Jan 2012 at 8:52

GoogleCodeExporter commented 9 years ago
@marc.gravell

Yes, I was trying to pass MyObject[].

Actually, I was passing int[] and MyObject[].  I just included 1 of the arrays 
in my example for simplicity.

Original comment by dlee33...@gmail.com on 31 Jan 2012 at 8:57

GoogleCodeExporter commented 9 years ago
Any updates regarding this... it still seems to be an issue in r580.

Original comment by jeff.a.z...@gmail.com on 6 Sep 2012 at 6:03

GoogleCodeExporter commented 9 years ago
Here is a patch that works for me.

@marc.gravell, would you consider integrating it ?

Thanks,

Original comment by michel.r...@gmail.com on 23 Oct 2012 at 3:01

Attachments:

GoogleCodeExporter commented 9 years ago
Sure - patch gratefully received.

Original comment by marc.gravell on 23 Oct 2012 at 3:04