Kamran Shahid
Kamran Shahid

Reputation: 4124

Unable to upload large file via nettcp binding and transfermode="buffered"

I have an application where in one of my method i am transferring file to the server.

I can upload around 50 KB of file easily. But my max limit would be around 3 MB.

My WCR service is hosted in windows service with nettcpbinding

My windows config is

<configuration>  
  <system.serviceModel>
    <services>
      <service name="BTWAServerWindowsService.BatchManagementService"
               behaviorConfiguration ="BatchManagementService">
        <host>
          <baseAddresses>
            <add baseAddress="net.tcp://localhost:9999/BatchManagementService" />
          </baseAddresses>
        </host>
        <endpoint name="BatchManagementServiceEndPoint"
        address =""
        binding="netTcpBinding"
        contract="BTWAServerWindowsService.IBatchManagementService">
        </endpoint>
        <endpoint name="BatchManagementServiceMetadataPoint" address="mex"
                binding="mexTcpBinding"
                contract="IMetadataExchange"/>
      </service>      
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="BatchManagementService">
          <serviceMetadata httpGetEnabled="False"/>
          <serviceDebug includeExceptionDetailInFaults="False" />
        </behavior>       
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
</configuration>

My Client config is

<configuration> 
  <system.serviceModel>
    <bindings>
      <netTcpBinding>
        <binding name="BatchManagementServiceEndPoint" closeTimeout="00:10:00"
          openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
          transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
          hostNameComparisonMode="StrongWildcard" listenBacklog="524288"
          maxBufferPoolSize="524288" maxBufferSize="524288" maxConnections="524288"
          maxReceivedMessageSize="524288">
          <readerQuotas maxDepth="524288" maxStringContentLength="524288"
            maxArrayLength="524288" maxBytesPerRead="524288" maxNameTableCharCount="524288" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
            enabled="false" />
          <security mode="Transport">
            <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
            <message clientCredentialType="Windows" />
          </security>
        </binding>       
      </netTcpBinding>
    </bindings>
    <client>
      <endpoint address="net.tcp://localhost:9999/BatchManagementService"
        binding="netTcpBinding" bindingConfiguration="BatchManagementServiceEndPoint"
        contract="BTWABatchManagement.IBatchManagementService" name="BatchManagementServiceEndPoint" />      
    </client>
  </system.serviceModel>
</configuration>

At the moment i am not in position of changing transfermode to streaming as there are also number of other methods

Kindly suggests me what would be the config change i required to increase my file limit to 4 mb

Upvotes: 1

Views: 961

Answers (1)

dera
dera

Reputation: 411

Make the changes for the following attributes in your netTcpBinding in your service side app.config and also in the client side app.config

maxBufferPoolSize="1073741824" maxBufferSize="1073741824" maxConnections="10"
          maxReceivedMessageSize="1073741824">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />

The max value of these attributes is 2147483647

<bindings>
      <netTcpBinding>
        <binding name="BatchManagementServiceEndPoint" closeTimeout="00:10:00"
          openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
          transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
          hostNameComparisonMode="StrongWildcard" listenBacklog="524288"
          maxBufferPoolSize="1073741824" maxBufferSize="1073741824" maxConnections="10"
          maxReceivedMessageSize="1073741824">
          <readerQuotas maxDepth="32" maxStringContentLength="2147483647"
            maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
          <reliableSession ordered="true" inactivityTimeout="00:10:00"
            enabled="false" />
          <security mode="Transport">
            <transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
            <message clientCredentialType="Windows" />
          </security>
        </binding>       
      </netTcpBinding>
</bindings>

Hope this helps

Upvotes: 2

Related Questions