Search code examples
c#.netazureasp.net-web-apiazure-service-fabric

Increase Message Size Service Fabric


I have hosted a Web API in Service Fabric and Posting data on it. Currently My object size is around 10 MB but default limit is 4 MB. I know its not a good practice to post such large objects but as per my need I have to do so.

Please help to increase the default message size limit.


Solution

  • While creating Service Listener, add this as a parameter to increase message size to be accepted by microservice in service-fabric.

        return new[]
        {
          new ServiceReplicaListener(con=> new 
          FabricTransporServiceRemotingListener(con,this,remotingListenerSettings: new 
          FabricTransportremotingListenerSettings(){
          MaxMessageSize = int.MaxValue;
          },serializationProvider: new ServiceRemotingSerializationProvider())),
        };
    

    This honors the message size to be increased which bypasses the default message size.