I have written a WCF service with NetTcp Binding.
<bindings>
<customBinding>
<binding name="CustomNetTcpBinding" closeTimeout="00:01:00" openTimeout="00:03:00" receiveTimeout="00:15:00" sendTimeout="00:15:00">
<transactionFlow />
<gZipMessageEncoding enableCompression="true" innerMessageEncoding="textMessageEncoding">
<readerQuotas maxDepth="999999999" maxStringContentLength="999999999" maxArrayLength="999999999" maxBytesPerRead="999999999" maxNameTableCharCount="999999999" />
</gZipMessageEncoding>
<windowsStreamSecurity />
<tcpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
<netTcpBinding>
<binding name="TcpAuthWindows" closeTimeout="01:01:00" openTimeout="01:10:00" receiveTimeout="01:10:00" sendTimeout="00:10:00" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="21474836470" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" algorithmSuite="Default" />
</security>
</binding>
</netTcpBinding>
</bindings>
I have hosted my WCF service on IIS.
Service is working fine till 105 concurrent calls after that it start giving me socket error as mentioned below...
The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '01:09:59.1099110'.
I have written my test case as per http://blogs.msdn.com/b/endpoint/archive/2011/05/04/wcf-scales-up-slowly-with-bursts-of-work.aspx
My questions are...
How does WCf handle requests after it's capacity. Is there any pipeline or queued up request.
How can I resolve this means no request should be errored out. It should wait until WCF service is free to accept new request.
THanks in advance.
WCF will Queue requests when the limit of conncurrent requests is reached.
It is not possible to Ensure that no request will fail, but you can reduce the chance that it will happen. For example the Client has a timeout, the Queue for Processing has a timeout.
For details on which parameters you can configure see:
http://weblogs.asp.net/paolopia/wcf-configuration-default-limits-concurrency-and-scalability
Related
I've just increased the number of methods in my ServiceContract. when I update the Service Reference in Visual Studio I get the message:
Metadata contains a reference that cannot be resolved:
'net.tcp://xxxxx.com:8002/DataQueryService/mex'.
There is an error in the XML document.
The maximum nametable character
count quota (16384) has been exceeded while reading XML data. The
nametable is a data structure used to store strings encountered during
XML processing - long XML documents with non-repeating element names,
attribute names and attribute values may trigger this quota. This
quota may be increased by changing the MaxNameTableCharCount property
on the XmlDictionaryReaderQuotas object used when creating the XML
reader.
The original server side config was:
<services>
<service behaviorConfiguration="XXXXX.DataQueryService.ServiceBehavior" name="XXXXX.DataQueryService.QueryService">
<host>
<baseAddresses>
<add baseAddress="net.tcp://xxxxx.com:8002/DataQueryService" />
</baseAddresses>
</host>
<endpoint name="MexEndpoint" address="mex" binding="customBinding" bindingConfiguration="unsecureTcpMex" contract="IMetadataExchange" />
</service>
</services>
<bindings>
<customBinding>
<binding name="unsecureTcpMex">
<tcpTransport portSharingEnabled="True" />
</binding>
</customBinding>
</bindings>
which I modified to:
<bindings>
<customBinding>
<binding name="unsecureTcpMex">
<textMessageEncoding>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</textMessageEncoding>
<tcpTransport portSharingEnabled="True" maxReceivedMessageSize="2147483647" />
</binding>
</customBinding>
</bindings>
What other changes do I need to make to my config to get this working?
Update
Following #Chris's advice I tried updating the config file for SVCUtil. I added a name to my endpoint so that it would match (updated above). The SvcUtil.config is now as follows:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="unsecureTcpMex">
<textMessageEncoding>
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</textMessageEncoding>
<httpTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint binding="customBinding" bindingConfiguration="unsecureTcpMex"
contract="IMetadataExchange"
name="MexEndpoint" />
</client>
</system.serviceModel>
</configuration>
<binding name="NameSoap" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true" messageEncoding="Text">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="4096" maxNameTableCharCount="1638400" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
Take a look to this line: maxNameTableCharCount="1638400"
I don't suppose its practical to split up the operations into multiple contracts? Mind if I ask how many service operations we're talking about?
Have you tried the solutions in this post?
http://social.msdn.microsoft.com/Forums/vstudio/en-US/17592561-c470-452a-a52c-2a5a2839582c/metadataexchangeclient-and-nametable-character-count-quota
Among other suggestions are using the Discovery protocol to read metadata, which does not have any reader quotas:
http://msdn2.microsoft.com/en-us/library/system.web.services.discovery.discoveryclientprotocol.aspx
The solution at the bottom suggests you change the default reader quotas in code before starting the service. I believe this would have to be done in a custom ServiceHost factory. Please let me know if you would assistance with that.
Hope this helps.
This should help:
http://geekswithblogs.net/claraoscura/archive/2007/08/20/114806.aspx
appears that the solution is to create a config file for svcutil and place it in the same folder as it.
Try setting the new value for the MaxNameTableCharCount property programmatically:
Binding binding = endpoint.Binding;
XmlDictionaryReaderQuotas myReaderQuotas = new XmlDictionaryReaderQuotas();
myReaderQuotas.MaxStringContentLength = something;
myReaderQuotas.MaxArrayLength = something;
myReaderQuotas.MaxBytesPerRead = something;
myReaderQuotas.MaxDepth = something;
myReaderQuotas.MaxNameTableCharCount = something;
binding.GetType().GetProperty("ReaderQuotas").SetValue(binding, myReaderQuotas, null);
Note: you have to set it BEFORE the client proxy and/or service host are created. Once created, they can't be changed.
I went through all the posts about this, nothing helped, so I posted this because I'm pulling my hair out.
I have a WCF web-service that has a method that receives a string, a long string. It works with a string of 2,390,158 characters (tried it) but won't work with a string of about 5,440,519 characters. (I'm using VS 2010)
I have this error:
System.ServiceModel.CommunicationException: An error occurred while receiving the HTTP response http:// localhost : 58014/ WSWebService.asmx. The reason may be that the connection endpoint service does not use the HTTP protocol. This may also be due to a HTTP request context has been ignored by the server (possibly due to the discontinuation of service).
I put all parameters I could at int.MaxValue (2,147,483,647) but it still won't work. Any help/suggestion is gladly appreciated.
I removed the "timeout" parts but it makes no difference :
closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
Here's the binding in my app.config:
<bindings>
<basicHttpBinding>
<binding name="WSWebServiceSoap" maxReceivedMessageSize="20971520"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
My config server side is :
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="WSWebServiceSoap" maxReceivedMessageSize="20971520"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
maxBufferSize="20971520" maxBufferPoolSize="20971520"
useDefaultWebProxy="true">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
So yes, same configuration. Am I missing something?
Service was ASMX based, redone it pure WCF and now it works.
I am using one WCF service that deployed in server designed in .net 4.0v . But after processing all queues it is generating exception i.e. service sent back a fault indicating it is too busy to process the request. Please retry later. Please see the inner exception for fault details. I am using "wsHttpBinding"
<customBinding>
<binding name="CustomSecurity">
<security>
<localServiceSettings maxPendingSessions="1000" />
<secureConversationBootstrap />
</security>
</binding>
</customBinding>
<binding name="CustomSecurityxxx" closeTimeout="01:00:00"
openTimeout="01:00:00" receiveTimeout="01:00:00" sendTimeout="01:00:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="1000000" maxReceivedMessageSize="1000000"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="01:00:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
Thanks in advance. Can anyone help me to solve this problem.
Yes it is fixed.
I increased the serviceThrottling values
<serviceThrottling maxConcurrentCalls="1000" maxConcurrentSessions="1000" maxConcurrentInstances="1000"/> from 200 and simply enclosed the service instances in using block so that the block will handle the scope of the object like initializing and disposing
Sample code syntax is as follows
xxxClient ServiceObject;
using (ServiceObject= new xxxClient())
{
try
{
your code goes here
}
catch (Exception ex)
{
ServiceObject.Abort();
}
}
Hope it will help to those facing the same problem.
I'm having problems setting up TransportWithMessageCredential on my wcf service.
Using the wcf Configuraton Editor, I set the Mode to TransportWithMessageCredential and the transportClientCredentialType to Windows in the web.config for the service and the app.config for my executable. I installed a self signed Cert on the erver and configured IIS to use it.
When I run my test app, I receive the following error:
System.InvalidOperationException: The username is not provided. Specify username in ClientCredentials.
It appears that the Windows credentials are not being passed to the wcf service and when i check the credentialCache.defaultCredentials, they are null. Any clues and/or tips on why this is and how to fix it? Thanks in advance
server 2003 / IIS 6.0 on an active directory domain.
web.config for service
<service name="Test.DiagnosticService">
<endpoint binding="basicHttpBinding" bindingConfiguration="WindowsTransportCredentialBinding" name="ClientDiagnosticEndpoint" contract="Test.IDiagnostic" />
</service>
<basicHttpBinding>
<binding name="WindowsTransportCredentialBinding" maxBufferSize="524288"
maxReceivedMessageSize="524288">
<readerQuotas maxDepth="128" maxStringContentLength="1048576" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Windows" proxyCredentialType="Windows" />
</security>
</binding>
app.config for executable
<client>
<endpoint address="https://U-WM-3vIntegr8/test/Web/Services/Diagnostic.svc"
binding="basicHttpBinding" bindingConfiguration="ClientHttpEndpoint"
contract="Test.IDiagnostic" name="ClientDiagnosticEndpoint" />
</client>
<basicHttpBinding>
<binding name="ClientHttpEndpoint" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:02:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="4194304" maxBufferPoolSize="524288" maxReceivedMessageSize="4194304"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="1048576"
maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Windows" proxyCredentialType="Windows"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
...Called from client
public static IDiagnostic GetDiagnosticService()
{
return new ChannelFactory<IDiagnostic>("ClientDiagnosticEndpoint").CreateChannel();
}
you need to manually fill in the credentials, they will not be automatically passed in this configuration. if that's what you look for you should set clientCredentialType to "Windows" on both client and server. Right now you need to set it manually:
proxy.ClientCredentials.Username.User = ""
proxy.ClientCredentials.Username.Password = ""
I'm using WindowsAuthentication in my silverlight application
Here is the setting that I have done in web.config
<authentication mode="Windows"/>
<basicHttpBinding>
<binding name="ServiceBinding" maxBufferSize="2147483647" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Ntlm" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
it's working fine ,but when ever i run fiddler, the application asks for the username and password! Does any one knows what is the reason behind that.
Thank you,
Naseem
In fiddler beta 2, there is a option "use proxy credentials".
Or you can customize the fiddler rule for your development server using:
if (oSession.HostnameIs("www.example.com")){
oSession.bypassGateway = true;
}
here is the link how to do it:
http://www.fiddler2.com/fiddler/dev/scriptsamples.asp