I have an application that is connect to wcf server for getting time async.
It's for keep connection alive by tcp.
So i want to detact that i disconnected from the server so i register to event faulted.
so far all good, but i find that the detection of disconnected is alwasy more than or equals to 20 deconds and i want to improve that, i think maybe by change settings of nettcp as follow i have right now:
<netTcpBinding>
<binding name="NetTcpBindingConf" closeTimeout="00:00:05" openTimeout="00:00:05" sendTimeout="00:00:10" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="100" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="20" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="5048576" maxArrayLength="50000" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<reliableSession ordered="true" inactivityTimeout="00:04:00" enabled="true"/>
<security mode="Transport">
<transport clientCredentialType="None" protectionLevel="EncryptAndSign"/>
<message clientCredentialType="Windows"/>
</security>
</binding>
</netTcpBinding>
I change to that:
<netTcpBinding>
<binding name="NetTcpBindingConf" closeTimeout="00:00:05" openTimeout="00:00:05" sendTimeout="00:00:05" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="100" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="20" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="5048576" maxArrayLength="50000" maxBytesPerRead="4096" maxNameTableCharCount="16384"/>
<reliableSession ordered="true" inactivityTimeout="00:00:05" enabled="true"/>
<security mode="Transport">
<transport clientCredentialType="None" protectionLevel="EncryptAndSign"/>
<message clientCredentialType="Windows"/>
</security>
</binding>
</netTcpBinding>
but it seems that still more than or equal to 20 seconds..
How to can i to improve?
I don't see that you set receiveTimeout for the binding. In my experience this is one of the most important ones.
Set it to 5 seconds as well.
sendTimeout is about how long to wait until message is sent. So, unless you send anything (call a method) there is nothing to monitor.
receiveTimeout is the opposite - for how long to wait before giving up.
Related
Here's a situation. We have a WCF service call with receive timeout being equal to 30 seconds. After 30 seconds the connection is aborted but the call is repeated. As a result, server performs the desired action twice, which is not what we want.
Binding configuration:
<netTcpBinding>
<binding name="DefaultTcpBinding"
maxReceivedMessageSize="901048576"
closeTimeout="00:00:30"
openTimeout="00:00:30"
receiveTimeout="00:00:30"
sendTimeout="00:00:30"
portSharingEnabled="false"
hostNameComparisonMode="StrongWildcard"
transactionFlow="true"
transactionProtocol="OleTransactions"
transferMode="Buffered"
maxConnections="50"
listenBacklog="50">
<reliableSession enabled="false"/>
<security mode="None">
<transport clientCredentialType="Windows" />
</security>
<readerQuotas maxDepth="32" maxStringContentLength="5242880"maxArrayLength="2147483646" maxBytesPerRead="4096" maxNameTableCharCount="5242880"/>
</binding>
</netTcpBinding>
Thanks in advance.
I am using a basic http binding and have set maxReceivedMessageSize="2147483647" on both the client and the service. My service is throwing an error however, with this message:
The maximum message size quota for incoming messages (65536) has been
exceeded. To increase the quota, use the MaxReceivedMessageSize
property on the appropriate binding element.
I know it's using my binding because that's the only one I've enabled and other method calls work fine. Is this just a generic message and my object is really bigger than 2147483647 not 65536?
The binding looks like this on both the client and server
<basicHttpBinding>
<binding name="basicHttpBinding" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="2147483647" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="16384" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
You likely have a name mismatch in the config between the name attribute of the <service> element and the actual service name. The name must be the fully-qualified name of the service class.
I have a VS 2010 solution containing a WCF service project and a unit test project. The unit test project has a service reference to the WCF service.
Web.config for the WCF service project sets a number of binding attributes to other-than-default values:
web.config: (Specifically note maxBufferSize="20000000")
<basicHttpBinding>
<binding name="basicHttpBindingConfig" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm"/>
</security>
</binding>
</basicHttpBinding>
While examining this issue, I came to realize that the unit test project's service reference support files do not contain the values I would expect (i.e. the values configured in the WCF service's web.config):
configuration.svcinfo:
(Specifically note maxBufferSize="65536")
<binding hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" messageEncoding="Text" name="BasicHttpBinding_IBishopService" textEncoding="utf-8" transferMode="Buffered">
<readerQuotas maxArrayLength="16384" maxBytesPerRead="4096" maxDepth="32" maxNameTableCharCount="16384" maxStringContentLength="8192" />
<security mode="None">
<message algorithmSuite="Default" clientCredentialType="UserName" />
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
</security>
</binding>
Deleting and re-creating the service reference or updating the service reference re-creates the files, but I still end up with the same values.
Why?
Update
Here's the app.config of the client
<binding name="BasicHttpBinding_IMyService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="200000000" maxBufferPoolSize="200000000" maxReceivedMessageSize="200000000"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="200000000" maxArrayLength="200000000"
maxBytesPerRead="200000000" maxNameTableCharCount="200000000" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
Same issue here and no solution after half a day messing about with config files... Changing automatically generated files is usually frowned upon, so my feeling says that "there has got to be a better way, Dennis".
UPDATE: I got my problem fixed by removing the name attribute in the binding configuration.
So your current web.config is looking like this
<basicHttpBinding>
<binding name="basicHttpBindingConfig" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm"/>
</security>
</binding>
</basicHttpBinding>
would become
<basicHttpBinding>
<binding maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32" maxArrayLength="200000000" maxStringContentLength="200000000"/>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm"/>
</security>
</binding>
</basicHttpBinding>
I think you only need to this at the client-side. By removing the name attribute, you essentially change the default basicHttpBinding configuration for your app, as far as I understand it. Credits for this solution here.
Another update: if you name your service configuration correctly (including the namespace) it will pick up the binding configuration. So instead of
<service name="ServiceName">
you need
<service name="My.Namespace.ServiceName">
That is correct behavior. Some information included in binding are specific to only one side of the configuration and both client and server can use completely different values. Also these values are defence against Denial of Service attach so service doesn't want to show them publicly.
Those values affects only processing of incoming messages so service configures how it will handle incoming requests and client configures how it will handle incoming responses. Requests and responses can have different characteristics and different configuration. There is no need for service to be configured to accept 1MB requests if it always receives only few KB requests and returns 1MB responses.
Btw. this is WCF specific feature not related to general web services and because of that there is no standardized way to describe this in WSDL.
I have some critical problem in my project. During transaction time with (wcf + netTCP)
I was getting the exception is.
The communication object,
System.ServiceModel.Channels.ClientFramingDuplexSessionChannel,
cannot be used for communication because it is in the Faulted state.
In WCF service app.config add binding tag with timeout specification. But my transaction has been ended within 10 min. what was the problem..
<bindings>
<basicHttpBinding>
<binding name="ServiceSoap" closeTimeout="0:01:00" openTimeout="0:01:00" receiveTimeout="10:00:00" sendTimeout="10:00:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
<netTcpBinding>
<binding name="b1" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="infinite" sendTimeout="10:00:00"
transferMode="Buffered"
maxBufferPoolSize="524288"
maxBufferSize="65536"
maxConnections="10"
maxReceivedMessageSize="65536">
<security mode="None" />
</binding>
</netTcpBinding>
</bindings>
Any one help me !!!..
I'm not sure why you think its a timeout issue? The error message doesn't suggest a timeout has ocured. Could the server be throwing an exception?
I would strongly recommend setting up WCF tracing. Its a bit involved but really worth doing as I've solved many obscure WCF issue with it.
This is not a complete answer but if you are using the client + server on the same machine you can use a named-pipe binding instead of netTcp
The binding section the configurations might look like this.
<netNamedPipeBinding>
<binding name="infiniteOpenBindingConfig" receiveTimeout="infinite" closeTimeout="infinite">
</binding>
</netNamedPipeBinding>
To keep the binding alive indefinitely the configuration above must be set both on server and client.
Try adding this to your netTcpBinding:
<reliableSession inactivityTimeout="infinite" enabled="true" />
And if that doesn't work, enable WCF tracing to find out what's killing it.
I have WCF client to send request to a service. And my business code call the client API to send 300+ requests per second. But my client only sends about 50 to service according to te performance counters of my service and WCF ServicePoint.
And I have increased ServicePointManager.DefaultConnectionLimit to 1000 in code, and setted maxConCurrentCalls to 1000 in service configuration file but got little improvement.
I guess there might be queue in WCF client for requests to send. Is there any way to configure it and speed up my client.
Here is my configuration for client:
<basicHttpBinding>
<binding name="Binding" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2000000" maxBufferPoolSize="524288" maxReceivedMessageSize="2000000"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
You may be hitting the connection limit for out going http connections:
<system.net>
<connectionManagement>
<add address="*" maxconnection="8"/>
</connectionManagement>
</system.net>
Note the default value is 2.