Why does my client send request so slowly? - wcf

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.

Related

NettcpBinding wcf - how to improve the time of detect faulted

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.

WCF service binding content type mismatch - text/xml and application/soap+xml

I have been at this for a few days trying to figure out why I am getting a content type mismatch error in my binding. There are countless other people that seem to be having this issue but all the resolutions don't apply or haven't worked.
I have looked everywhere trying to figure out why I am getting the following error:
Server Error in '/' Application.
The content type application/soap+xml; charset=utf-8 of the response message does not match the content type of the binding (text/xml; charset=utf-8). If using a custom encoder, be sure that the IsContentTypeSupported method is implemented properly. The first 823 bytes of the response were:
<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><GetQuoteResponse xmlns="http://soap.service.GMO.com"><Quote_Response><errorMessage></errorMessage><return_List><item><errorMessage></errorMessage><monthlyPremiumAmount>6.0</monthlyPremiumAmount><webID>7P3W4Txst</webID><basePer1>1000.0</basePer1><basePer2>0.0</basePer2><baseRate1>0.05</baseRate1><baseRate2>0.0</baseRate2><benefitID>5365</benefitID><coverageAmount>100000</coverageAmount><grossPer1>1000.0</grossPer1><grossPer2>0.0</grossPer2><grossRate1>0.06</grossRate1><grossRate2>0.0</grossRate2></item></return_List></Quote_Response></GetQuoteResponse></soapenv:Body></soapenv:Envelope>.
The web service I am consuming is not hosted in IIS. The web service itself seems to be working properly because we use SoapUI and get all the proper results returned to us. As you can also see from the above error message, values are being returned from the web service.
I have also been using Fiddler and am able to confirm that the request header content type is text/xml and the response header content type is application/soap+xml.
We have a datalayer where the service reference resides. The app.config looks like this:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="IMSQuoteServiceBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01: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>
</bindings>
<client>
<endpoint address="http://hostingServerName:81/cgi-bin/jsmdirect?IMSQuote"
binding="basicHttpBinding" bindingConfiguration="IMSQuoteServiceBinding"
contract="Quote.IMSQuoteServicePortType" name="IMSQuoteServicePort" />
</client>
</system.serviceModel>
The web site web.config looks like this:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="IMSQuoteServiceBinding" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01: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>
</bindings>
<client>
<endpoint address="http://hostingServerName:81/cgi-bin/jsmdirect?IMSQuote"
binding="basicHttpBinding" bindingConfiguration="IMSQuoteServiceBinding"
contract="Quote.IMSQuoteServicePortType" name="IMSQuoteServicePort" />
</client>
Any help would be very much appreciated. I am somewhat new to WCF and am open to any and all ideas.
Thank you all in advance for your help. If you need me to provide any more information, please let me know.
Just as an update.
I changed the service binding from basicHttpBinding to wsHttpBinding. Changing the binding to wsHttpBinding changed the SOAP service to send as a SOAP 1.2 call rather than a SOAP 1.1 call. Once I did this, the content types matched on the send and receive calls which resolved the binding mismatch error.

How to prevent WCF from calling service method multiple times if exception was thrown?

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.

call third party web service from wcf service

I have to call a third party web service from my WCF service library. When I call the third party web service from a test application, there is no problem, but when I call from my WCF service, there is an error:
An error occurred while receiving the HTTP response to xxx.svc/ws.
This could be...
I've added third party web service with Add Service Reference. Bindings for that web service is generated automatically as:
<wsHttpBinding>
<binding name="WSHttpBinding_xxxService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" />
</security>
</binding>
</wsHttpBinding>
Bindings of my WCF service are different:
<basicHttpBinding>
<binding name="basicHttpBinding" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01: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>
Bindings for my WCF service are automatically generated in test app.config file, but bindings for third party service is generated only inside WCF appl config.
What am I doing wrong?
I've found a solution. The problem was that web application didn't use web service configuration configured in web config file. It always made direct call instead through proxy. So I called web service from code, and input same settings as in web config for web service programatically and added proxy address through which it can pass through my network.

WCF + net.tcp Communication Timeout problem

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.