Error with WCF configuration for MaxReceivedMessageSize - wcf

I am getting the following error when calling my service;
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.
The configuration of the service is;
<bindings>
<basicHttpBinding>
<binding name="basic" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="32" maxStringContentLength="67108864" maxArrayLength="10240000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="Company.Product.Service.FileManager.IFileManager">
<endpoint binding="basicHttpBinding" bindingConfiguration="basic" name="FileManager" bindingNamespace="Company.Product.FileManager.FileManagerService" contract="Company.Product.Service.FileManager.IFileManager" />
<host>
<baseAddresses>
<add baseAddress="http://filemanager.dev.v7.services.Company.net" />
</baseAddresses>
</host>
</service>
</services>
As you can see, I have adjusted the settings accordingly, so not sure why I am still getting this error.
Client Configuration;
<bindings>
<basicHttpBinding>
<binding name="basic" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="67108864" maxArrayLength="10240000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://filemanager.dev.v7.services.Company.net/service.svc" binding="basicHttpBinding" bindingConfiguration="basic" contract="Company.Product.Service.FileManager.IFileManager" name="FileManager"/>
</client>
Update
Changing the service configuration to this (removed the binding name) and this now works, but why would it not work with a named configuration;
<bindings>
<basicHttpBinding>
<binding name="" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" >
<readerQuotas maxDepth="32" maxStringContentLength="67108864" maxArrayLength="10240000" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</binding>
</basicHttpBinding>
</bindings>

You have to change the app.config of your client as well.
Edit:
If you leave the name attribute empty it will be applied to every binding of the type that is not named. If you have a named binding in the config it will only be picked up if it is explicitly referenced by that name.

Related

The maximum message size quota for incoming messages has been exceeded

I would like to ask for your help because sometimes I get an error message when I call a service : 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.
On one side :
<bindings>
<basicHttpBinding>
<binding name="BasicHttp" bypassProxyOnLocal="true"
maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"
transferMode="Buffered">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<security mode="None" />
</binding>
</basicHttpBinding>
<webHttpBinding>
<binding name="WebHttp" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</webHttpBinding>
</bindings>
<client>
<endpoint address="http://xxx:7575/MyRequest.svc" behaviorConfiguration="webhttp"
binding="webHttpBinding" bindingConfiguration="WebHttp"
contract="MyService.Service.Contract.IRequestService" name="MyServiceEndpoint" />
</client>
on the other side (xxx) :
<system.serviceModel>
<services>
<service name="MyService.Service.RequestService" behaviorConfiguration="ServiceEndpointBehavior">
<endpoint address="" binding="webHttpBinding" contract="MyService.Service.Contract.IRequestService" behaviorConfiguration="RestEndPointBehavior" bindingConfiguration="WebHttp"/>
</service>
</services>
<bindings>
<basicHttpBinding>
</basicHttpBinding>
<webHttpBinding>
<binding name="WebHttp" allowCookies="true" maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" maxBufferPoolSize="2147483647">
<readerQuotas maxDepth="32" maxArrayLength="2147483647" maxStringContentLength="2147483647"/>
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
Jojo
I tried several things following the different topics with the same error on "stackoverflow" but nothing works. Thanks in advance
As far as I know, if increasing this value alone doesn't work you may also increase the value of httpRuntime.
If this doesn't work, try BasicHttpBinding.

Can't get WCF Host configuration to a client with adding Service Reference

I prepared a wcf service host and configured with some binding information below.
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" />
</webHttpEndpoint>
</standardEndpoints>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding" closeTimeout="00:02:00" openTimeout="00:02:00"
receiveTimeout="00:20:00" sendTimeout="00:02:00" transactionFlow="true"
transferMode="Buffered" maxBufferPoolSize="2147483647"
maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="None">
<transport protectionLevel="None" />
</security>
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="tcpServiceBehavior">
<serviceMetadata httpGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service behaviorConfiguration="tcpServiceBehavior" name="MyClass">
<endpoint address="" binding="netTcpBinding" bindingConfiguration="NetTcpBinding" contract="IMyClass">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:8732/Design_Time_Addresses/MyService/MyClass" />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
And instantiate with the code below:
ServiceHost wcfHost = new ServiceHost(typeof(MyClass));
wcfHost.Open();
Using QuickWatch checked it out and verified the configuration values. Then, I added Service Reference on "net.tcp://localhost:8732/Design_Time_Addresses/MyService/MyClass" to an other project. So, the new config file below has been created in the client project.
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IMyClass" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
maxReceivedMessageSize="65536">
<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" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:8732/Design_Time_Addresses/MyService/MyClass" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IMyClass" contract="IMyClass" name="NetTcpBinding_IMyClass">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
The problem is the binding configuration of host can't come to client. If I change client configuration it doesn't affects. For example, changed maxStringContentLength value from 8192 to 2147483647, then, saw that client has been instantiated with correct config but, operated with old config. Searched "8192" in solution and found in .svcinfo files as XML scheme. How can I solve this weird situation?
Right click the service reference and "Update" the it and VS will regenerate the svcinfo files, or you could avoid this issue entirely by not using VS to create the service proxy and instead generating your own service proxy by hand (considered a best practice as far as I know). As you already noted, "Add Service Reference" is not smart enough to take all those configuration values from the service when creating a client.

WCF charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8)

I'm hosting a WCF service in IIS 7.5 using .NET 4.0. I also have a WPF application that I am using as my client that was built with Visual Studio 2010 and .NET 4.0. I added my service reference and when I attempt to call a function, I get the following exception
The content type application/xml; charset=utf-8 of the response message does not match the content type of the binding (application/soap+xml; charset=utf-8)
I am able to navigate to the service in a web browser and my bindings appear to be the same between the client and service (WsHttp bindings).
I know there are alot of google results about this error but none of them seemed to be relevant/help my specific problem. I tried installing Non-HTTP Activation features as well as a wide variety of other small tricks. Anybody be able to help? Thanks
edit, here are my configs (they are quite lengthy)
Client
<?xml version="1.0"?>
<configuration>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="ContentSoap"
closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01: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="8192"
maxArrayLength="2147483647"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
<binding name="OrderSoap"
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>
<netTcpBinding>
<binding name="NetTcpBindingEndpoint" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
transactionFlow="false" transferMode="Buffered"
transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="2147000000" maxBufferSize="65536" maxConnections="10"
maxReceivedMessageSize="2147000000">
<readerQuotas maxDepth="32" maxStringContentLength="8192"
maxArrayLength="2147000000" maxBytesPerRead="4096"
maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:01:00"
enabled="true" />
<security mode="None">
<transport clientCredentialType="Windows"
protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
<wsHttpBinding>
<binding name="WSHttpBinding_IInmateCanteenServiceWeb"
closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false"
hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
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="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint name="ContentSoap"
address="http://media.team.twvending.net/storeservices/content.asmx"
binding="basicHttpBinding" bindingConfiguration="ContentSoap"
contract="MediaPortContent.ContentSoap" />
<endpoint name="OrderSoap"
address="http://media.team.twvending.net/storeservices/order.asmx"
binding="basicHttpBinding" bindingConfiguration="OrderSoap"
contract="MediaPortOrder.OrderSoap" />
<endpoint name="NetTcpBindingEndpoint"
address="..."
binding="netTcpBinding" bindingConfiguration="NetTcpBindingEndpoint"
contract="WebCallBack.ICallbackService" />
<endpoint name="WSHttpBinding_IInmateCanteenServiceWeb"
address="..."
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IInmateCanteenServiceWeb"
contract="InmateCanteenWeb.IInmateCanteenServiceWeb" />
<endpoint name="WSHttpBinding_ICommAccountingBinding"
address="..."
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IInmateCanteenServiceWeb"
contract="CommAccountingWeb.ICommAccountingWeb" />
</client>
</system.serviceModel>
and Server
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="httpBehavior">
<!--<webHttp />-->
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceCredentials>
<clientCertificate>
<authentication revocationMode="NoCheck" />
</clientCertificate>
<serviceCertificate findValue="CN=secure.inmatecanteen.com" />
</serviceCredentials>
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="MexBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="HttpMexBehavior">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="BasicHttpMexBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
<behavior name="">
<serviceMetadata httpsGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="false"
multipleSiteBindingsEnabled="true" />
<bindings>
<wsHttpBinding>
<binding name="myWsHttpBinding" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647" messageEncoding="Text">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</wsHttpBinding>
<webHttpBinding>
<binding name="myWebHttpBinding">
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
</security>
</binding>
</webHttpBinding>
<basicHttpBinding>
<binding name="myBasicHttpBinding" maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
</basicHttpBinding>
</bindings>
<services>
<service name="CommAccountingWeb.CommAccountingWeb"
behaviorConfiguration="HttpMexBehavior">
<endpoint
address=""
behaviorConfiguration="httpBehavior"
binding="webHttpBinding" bindingConfiguration="myWebHttpBinding"
contract="CommAccountingWeb.ICommAccountingWeb" />
<endpoint
address="mex"
binding="mexHttpsBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="..."></add>
</baseAddresses>
</host>
</service>
<service name="CommAccountingWeb.CommAccountingBasic"
behaviorConfiguration="BasicHttpMexBehavior">
<endpoint
address=""
binding="basicHttpBinding"
bindingConfiguration="myBasicHttpBinding"
contract="CommAccountingWeb.ICommAccountingBasic" />
<endpoint
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="..." />
</baseAddresses>
</host>
</service>
</services>
</system.serviceModel>
As I suspected - your client-side config looks like this:
<endpoint name="WSHttpBinding_ICommAccountingBinding"
address="https://secure.inmatecanteen.com/CommAccountingService/CommAccountingWeb.svc"
binding="wsHttpBinding"
bindingConfiguration="WSHttpBinding_IInmateCanteenServiceWeb"
contract="CommAccountingWeb.ICommAccountingWeb" />
It expects wsHttpBinding - but the server-side address it's connecting to is:
<service name="CommAccountingWeb.CommAccountingWeb"
behaviorConfiguration="HttpMexBehavior">
<endpoint
address=""
behaviorConfiguration="httpBehavior"
binding="webHttpBinding" bindingConfiguration="myWebHttpBinding"
contract="CommAccountingWeb.ICommAccountingWeb" />
<host>
<baseAddresses>
<add baseAddress="https://secure.inmatecanteen.com/CommAccountingService/CommAccountingWeb.svc"></add>
</baseAddresses>
</host>
</service>
and this server endpoint uses webHttpBinding.
So while the client expects a SOAP XML message (content type: application/soap+xml; charset=utf-8), the server-side endpoint is a REST endpoint which returns plain XML (content type: application/xml; charset=utf-8)
Solution: you need to make sure both the client and the server endpoint used are in sync with regards to bindings and configuration!
As Steven Westbrook says in a comment on this answer:
Add ?wsdl to your client's endpoint address, and you should have more luck with the service. ?wsdl is important - it means the browser is just getting "Web Services Description Language" for the service, and not calling the service.
I had the same issue and adding ?wsdl solved my headache.
I came across a similar error while creating a client service to one of the existing server side WebService. I could rectify it using SOAP 1.1 transport protocol on the client. Somehow soap 1.2 is giving/expecting a different format. This trace back to the difference between BasicHttpBinding vs WebHttpBinding vs WsHttpBinding.
I got this problem after I added a method that returned a collection of instances of a base class that didn't have a [KnownType] attribute that would resolve to a concrete instance.
With the [KnownType] attribute in place the problem disappeared.
[ServiceContract]
public interface IService {
[OperationContract]
IEnumerable<ItemBase> GetItems();
}
[DataContract]
// [KnownType(typeof(RealItemA))] <--- without these attributes you will get a problem
// [KnownType(typeof(RealItemB))]
public class ItemBase {
}
[DataContract]
public class RealItemA : ItemBase {
}
[DataContract]
public class RealItemB : ITemBase {
}
in my case same error was caused by missing
[datacontract]
[datamember]
attributes in returned data type.
Error message was really misleading.
In my case a specific service was using SOAP 1.1 instead of the usual 1.2.
I had to change the binding from this:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="ServiceSoapBinding">
<textMessageEncoding messageVersion="Soap12"/>
</binding>
</customBinding>
</bindings>
</system.serviceModel>
To this:
<system.serviceModel>
<bindings>
<customBinding>
<binding name="ServiceSoapBinding">
<textMessageEncoding messageVersion="Soap11"/>
</binding>
</customBinding>
</bindings>
</system.serviceModel>

Issue on max readers quotas in WCF web service

The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:GetFileResult. The InnerException message was 'There was an error deserializing the object of type WindowsClient.CloudServiceProxy.GetFileResponse. The maximum array length quota (16384) has been exceeded while reading XML data. This quota may be increased by changing the MaxArrayLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 1, position 41572.'. Please see InnerException for more details.
I am getting this issue the
sever web.config is
<system.serviceModel>
<services>
<service behaviorConfigura
tion="CloudServiceBehaviour" name="Web.CloudService">
<endpoint name="CloudServiceClientEndPoint" bindingConfiguration="CloudBindingConfig" address="http://localhost:53243/CloudService.svc" binding="wsHttpBinding" contract="Web.ICloudService"></endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="CloudServiceBehaviour">
<serviceMetadata httpGetEnabled="True" httpGetUrl=""/>
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<wsHttpBinding>
<binding name="CloudBindingConfig" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="200" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</wsHttpBinding>
</bindings>
</system.serviceModel>
and the client web.config is ,
<system.serviceModel>
<bindings>
<wsHttpBinding>
<binding name="CloudServiceClientEndPoint" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:30:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:30:00"
enabled="false" />
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:53243/CloudService.svc" binding="wsHttpBinding"
contract="CloudServiceProxy.ICloudService" name="CloudServiceClientEndPoint" />
</client>
</system.serviceModel>
Since the error is while deserializing the GetFileResponse object, that tells you the problem is in the client-side stack.
Your client side binding is using the default configuration for wsHttpBinding because you have omitted to specify the bindingConfiguration name on the endpoint. Try adding bindingConfiguration="CloudServiceClientEndPoint" to the endpoint element and then your large values for the readerQuotas settings will be picked up.

WCF Custom binding - send timeout always reached

I have a wcf service that needs to implement callbacks and be hosted on IIS 6.0. Since IIS 6.0 doesn't support the net.tcp binding, I decided to use a custom binding because the service is accessed by different clients in different timezones and, using custom binding, I can set the allowed clock skew time to values other than the default one.
Here is my server config file:
<bindings>
<customBinding>
<binding name="pscNetBinding" openTimeout="00:10:00">
<reliableSession acknowledgementInterval="00:00:00.2000000"
flowControlEnabled="true" inactivityTimeout="23:59:59"
maxPendingChannels="128" maxRetryCount="8" maxTransferWindowSize="128"
ordered="true" />
<compositeDuplex />
<oneWay maxAcceptedChannels="128" packetRoutable="false">
<channelPoolSettings idleTimeout="00:10:00"
leaseTimeout="00:10:00" maxOutboundChannelsPerEndpoint="10" />
</oneWay>
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Default" writeEncoding="utf-8">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</textMessageEncoding>
<httpTransport manualAddressing="false"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="2147483647"
proxyAuthenticationScheme="Anonymous" realm="" transferMode="Buffered"
unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true"/>
</binding>
</customBinding>
</bindings>
<services>
<service name="SchneiderElectric.PSCNet.Server.Services.PSCNetWCFService" behaviorConfiguration="Behaviors1">
<host>
<baseAddresses>
<add baseAddress ="http://10.155.18.18:2000/PSCNet"/>
</baseAddresses>
</host>
<endpoint address="" binding="customBinding" bindingConfiguration="pscNetBinding"
contract="SchneiderElectric.PSCNet.Server.Contracts.IPSCNetWCFService"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="Behaviors1">
<serviceMetadata httpGetEnabled = "true"/>
<!--<serviceThrottling maxConcurrentCalls="2048" maxConcurrentSessions="2048" maxConcurrentInstances="2048" />
<dataContractSerializer maxItemsInObjectGraph="2147483647" />-->
</behavior>
</serviceBehaviors>
</behaviors>
Client config file:
<bindings>
<customBinding>
<binding name="pscNetBinding" openTimeout="00:10:00">
<reliableSession acknowledgementInterval="00:00:00.2000000"
flowControlEnabled="true" inactivityTimeout="23:59:59"
maxPendingChannels="128" maxRetryCount="8" maxTransferWindowSize="128"
ordered="true" />
<compositeDuplex />
<oneWay maxAcceptedChannels="128" packetRoutable="false">
<channelPoolSettings idleTimeout="00:10:00"
leaseTimeout="00:10:00" maxOutboundChannelsPerEndpoint="10" />
</oneWay>
<textMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Default" writeEncoding="utf-8" >
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647" maxArrayLength="2147483647"
maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</textMessageEncoding >
<httpTransport manualAddressing="false"
maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647"
allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="2147483647"
proxyAuthenticationScheme="Anonymous" realm="" transferMode="Buffered"
unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://10.155.18.18:2000/PSCNet" binding="customBinding"
bindingConfiguration="pscNetBinding" contract="PSCNetWCFService.IPSCNetWCFService"
name="pscNetBinding" />
</client>
If I use the server and client on the same machine, everything works fine. If I run them on different machines, I get the following error:
Could not connect to
http://10.155.18.198:9000/e60ba5b3-f979-4922-b9f8-c820caaa04c2. TCP
error code 10060: A connection attempt failed because the connected
party did not properly respond after a period of time, or established
connection failed because connected host has failed to respond
10.155.18.198:9000.
Can anyone in the community help me in this regard?
Can you show the part of the config where you're defining the customBinding? Maybe you just didn't paste that part in, but when you define a custom binding, you have to specify an encoding and a transport at minimum - something like this:
<bindings>
<customBinding>
<binding name="MyCustomTextTcpBinding">
<textMessageEncoding />
<tcpTransport />
</binding>
</customBinding>
</bindings>
Can you also paste in the part where you're defining your "pscNetBinding" bindingConfiguration?
Windows service is undoubtely a nice solution but i think a better would be a self hosting
and you could have anytype of binding on it.