0

When I receive bytes array over 350 MB, I am getting error as "The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error."

Client side config

  var binding = new NetTcpBinding(SecurityMode.None)
        {
            PortSharingEnabled = true,
            MaxBufferSize = Int32.MaxValue,
            MaxReceivedMessageSize = Int32.MaxValue,
            ReaderQuotas = new XmlDictionaryReaderQuotas
            {
                MaxArrayLength = Int32.MaxValue,
                MaxBytesPerRead = Int32.MaxValue,
                MaxDepth = Int32.MaxValue,
                MaxNameTableCharCount = Int32.MaxValue,
                MaxStringContentLength = Int32.MaxValue,
            },

            MaxBufferPoolSize = 0,
            TransactionFlow = false,
            TransactionProtocol = TransactionProtocol.Default,
            TransferMode = TransferMode.Streamed,
            OpenTimeout = new TimeSpan(0, 10, 0),
            CloseTimeout = new TimeSpan(0, 10, 0),
            SendTimeout = new TimeSpan(0, 10, 0),
            ReceiveTimeout = new TimeSpan(0, 10, 0)
        }; 

container.Register(Component.For<IFtpsServiceFacade>()
            .AsWcfClient(
                new DefaultClientModel(
                    WcfEndpoint.BoundTo(binding)
                       .At(string.Format("net.tcp://{0}/FileService.Ftps",
                            "localhost")))
            )); 

Server side config.

var binding = new NetTcpBinding
        {
            PortSharingEnabled = true,
            MaxBufferSize = Int32.MaxValue,
            MaxReceivedMessageSize = Int32.MaxValue,
            ReaderQuotas = new XmlDictionaryReaderQuotas
            {
                MaxArrayLength = Int32.MaxValue,
                MaxBytesPerRead = Int32.MaxValue,
                MaxDepth = Int32.MaxValue,
                MaxNameTableCharCount = Int32.MaxValue,
                MaxStringContentLength = Int32.MaxValue,
            },
            MaxBufferPoolSize = 0,
            TransactionFlow = false,
            TransactionProtocol = TransactionProtocol.Default,
            TransferMode = TransferMode.Buffered,
            OpenTimeout = new TimeSpan(0, 10, 0),
            CloseTimeout = new TimeSpan(0, 10, 0),
            SendTimeout = new TimeSpan(0, 10, 0),
            ReceiveTimeout = new TimeSpan(0, 10, 0)
        }; 
        container.Register(Component.For<IFtpsServiceFacade>()
          .ImplementedBy<FtpsServiceFacade>()
          .AsWcfService(
              new DefaultServiceModel()
                  .AddEndpoints(
                      WcfEndpoint.BoundTo(binding)
                           .At(string.Format("net.tcp://{0}/FileService.Ftps",
                              "localhost"))
                  )).LifestyleSingleton() );
dragullar
  • 345
  • 3
  • 5
  • 19

1 Answers1

-1

The establishment of the communication channel between the server-side and the client-side requires that the server-side and the client-side have the same binding settings. Therefore, the above error occurred. In order to solve this problem, we should change the settings on the server-side instead of the client-side. The max size of the supported file above 2GB, finished by the below configuration.

NetTcpBinding binding = new NetTcpBinding();
            binding.Security.Mode = SecurityMode.None;
            binding.MaxBufferSize = Int32.MaxValue;
            binding.MaxBufferPoolSize = Int32.MaxValue;
            binding.MaxReceivedMessageSize = Int32.MaxValue;

Especially to the security mode, it should be fully consistent with the setting located on the client-side. Feel free to let me know if the problem still exists.

Abraham Qian
  • 7,117
  • 1
  • 8
  • 22
  • I would like to know the configuration of the server-side. and the client configuration automatically generated by Adding service reference. We may forget to apply the binding configuration to the service endpoint. – Abraham Qian Apr 29 '20 at 07:21
  • Abraham Qian , I have updated my question, I add server and client config – dragullar Apr 29 '20 at 07:56
  • _"The establishment of the communication channel"_ - no, that has been established way before you get this error. _"requires that the server-side and the client-side have the same binding settings"_ - no, you can perfectly configure your client to only send 1 MB messages while the server accepts messages of 1 GB. While you may have a point that in this case some part of some config is restricting message size, your claims are incorrect. – CodeCaster Apr 29 '20 at 08:00
  • @dragullar, try to set up the MaxBufferPoolSize attribute. besides, see this link, wishing it is useful to you. https://stackoverflow.com/questions/16173835/wcf-error-the-server-did-not-provide-a-meaningful-reply – Abraham Qian Apr 29 '20 at 08:40