i have wcf service and i am sending large streams from service to client.
this is my code in client web config
<bindings>
<basicHttpBinding>
<binding name="Blabla" allowCookies="true"
maxReceivedMessageSize="2147483647"
maxBufferSize="2147483647"
maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="32"
maxArrayLength="2147483647"
maxStringContentLength="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
when i wanted to set maxReceivedMessageSize to more than 2 gb, i get an error. it says "int32 value can not initialize that value". Is it possible to set it to 40 gb or bigger value?
maxReceivedMessageSize can be set to more than int.MaxValue, but only if the transfer mode of the binding is set to Streamed. You should also not set maxBufferSize to 2GB, otherwise you may get a huge memory usage in the client.
Related
added maximum size on web config, but still showing the same error.
ERROR IMAGE
You need to set maxReceivedMessageSize both in your server-side and client-side. The code like this:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding maxBufferSize="64000000" maxReceivedMessageSize="2147483647" />
</basicHttpBinding>
</bindings>
</system.serviceModel>
Always getting exception "The maximum message size quota for incoming messages has been exceeded for the remote channel. See the server logs for more details", in .net c# wcf windows application development.
Up to approximate 72kb size data in DataTable I am able to send remote machine hosting WCF in windows service successfully. But above that throwing exception "The maximum message size quota for incoming messages has been exceeded for the remote channel. See the server logs for more details".
Already did setup of data size management both end.
Client-end App.config:
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IProjectService"
maxBufferSize="2147483647" maxBufferPoolSize="524288"
maxReceivedMessageSize="2147483647">
<readerQuotas maxStringContentLength="2147483647"/>
</binding>
</netTcpBinding>
</bindings>
Remote server-end App.config:
<netTcpBinding>
<binding name="NetTcpBinding_IProjectService" maxBufferSize="2097152"
maxBufferPoolSize="2097152"maxReceivedMessageSize="2097152">
<readerQuotas maxStringContentLength="2097152" />
</binding>
</netTcpBinding>
Also tried same sizes i.e."2147483647" both-end but with same exception always.
Please consider the below configuration.
<bindings>
<netHttpBinding>
<binding name="mybinding" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxArrayLength="2147483647" maxStringContentLength="2147483647"/>
</binding>
</netHttpBinding>
</bindings>
Moreover, please apply the configuration in the service endpoint by using BindingConfiguration name.
<services>
<service name="sv">
<endpoint bindingConfiguration="mybinding" address="" binding="netTcpBinding" contract="isv" ></endpoint>
</service>
</services>
Please apply the configuration on both the serve-end and the client-end.
Feel free to let me know if the problem still exists.
Previously I am sending file (less than 63 KB ) through WCF Rest service then it send successfully but when the file size is greater than 65 KB, it throws an exception. After that I configure the web.config file like below and it works fine.
<bindings>
<webHttpBinding>
<binding maxReceivedMessageSize="10485760">
<readerQuotas/>
</binding>
</webHttpBinding>
</bindings>
Now i am sending 10 MB file and also increase the size in web.config file but got the same exception.
I added below configuration setting :
<bindings>
<webHttpBinding>
<binding maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" >
<readerQuotas maxStringContentLength="525288"></readerQuotas>
</binding>
</webHttpBinding>
</bindings>
What is needed to fix this?
I guess you receive this error on client side. remember you have to set the max size at client side!!!
Read Derek's answer. Thats really helpfull.
Our WCF service on large request returns following error:
"System.ServiceModel.EndpointNotFoundException: There was no endpoint listening at http://xxx.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details. ---> System.Net.WebException: The remote server returned an error: (404) Not Found.
For small requests everything works fine and I am getting correct response from WCF service, the issue is only with large requests.
Settings on the client are as follow:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_ITestService" openTimeout="00:05:00" sendTimeout="00:05:00" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="2147483647" maxBytesPerRead="2147483647" maxArrayLength="2147483647" maxStringContentLength="2147483647"
maxNameTableCharCount="2147483647"/>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:33333/TestService.svc" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding_ITestService" contract="TestService.ITestService" name="BasicHttpBinding_ITestService" />
</client>
</system.serviceModel>
The settings of the WCF service:
<bindings>
<basicHttpBinding>
<binding maxReceivedMessageSize="2147483647" receiveTimeout="00:10:00" sendTimeout="00:10:00" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483646" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
What can be the issue?
In this case, the error was not with WCF but with the IIS settings.
The Message was to large for IIS, I have added "maxAllowedContentLength" to the web.config on the server.
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2200000000"/>
</requestFiltering>
</security>
The error message was misleading.
In my case, it was not working even after trying all solutions and setting all limits to max. In last I found out that a Microsoft IIS filtering module Url Scan 3.1 was installed on IIS/website, which have it's own limit to reject incoming requests based on content size and return "404 Not found page".
It's limit can be updated in %windir%\System32\inetsrv\urlscan\UrlScan.ini file by setting MaxAllowedContentLength to the required value.
For eg. following will allow upto 300 mb requests
MaxAllowedContentLength=314572800
Error in deserializing body of reply message for operation 'CreateTransactionEntity'. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader.
Hey, I keep getting this error even though I have a larger-than-life readerQuota node on my web.config file...
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="BindingTcp" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" closeTimeout="00:10:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</netTcpBinding>
After browsing the internet on the subject, I can't seem to come up with a decent answer. If you have any advice I would really appreciate it.
In order to ensure the values you specify for the binding are picked up, you must assign the Name of the binding from the <binding> element to the bindingConfiguration attribute of the the <endpoint> element. If you don't, WCF will use the default values for the specified binding.
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="BindingTcp" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" closeTimeout="00:10:00">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</netTcpBinding>
In the example above, you have assigned "BindingTCP" as the name in your <binding> element. So in your endpoint do this:
<endpoint address="net.tcp://some.website.url/yourserivce" binding="netTcpBinding" bindingConfiguration="BindingTCP" contract="IYourContract" />
Depending on where the error is (on the client or on the server) will determine which config file needs to be modified. If the error is happening on both ends, modify both config files.
You should check your client application to know if it uses default binding configuration. The quicker way to confirm this is to capture WCF traces at verbose level and check events of Construct ChannelFactory activity.
HTH,
Amit Bhatia