I am facing issue of poor performance when used WCF having NetTcpbinding with Load Balancer
We have win form application which consumes WCF (net.tcp protocol). In production we have web Farm having 3 servers with load balancer (F5). WCF hosted in IIS. We are testing with only 1 user
Now when we point WCF to specific server (using either server name or IP); application really perform well. However when we give the DNS name (so that request is pass through load balancer) there is a significant drop in performance. Network team is saying from there side everything is properly working. Please help
Following is the configuration that i have tin WCF web.config file.
<system.serviceModel>
<diagnostics performanceCounters="All" />
<services>
<service behaviorConfiguration="GetProxyEnabled" name="companyname.InvOps.ServiceLayer.PAServiceServer">
<host>
<baseAddresses>
<add baseAddress="net.tcp://USHOUIOWEB012VT/PAService"/>
<!--<add baseAddress="net.tcp://xxx.uat.companyname.net/PAService/"/>-->
</baseAddresses>
</host>
<endpoint address="netTcpAddress" behaviorConfiguration="NetTcpEndPointBehaviour" binding="netTcpBinding" bindingConfiguration="NetTcpBinding" contract="companyname.InvOps.ServiceLayer.IPAService" />
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="GetProxyEnabled">
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceThrottling maxConcurrentCalls="200" maxConcurrentInstances="400" maxConcurrentSessions="200"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="NetTcpEndPointBehaviour">
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
</behavior>
</endpointBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding"
closeTimeout="05:45:00"
openTimeout="05:45:00"
receiveTimeout="05:45:00"
sendTimeout="05:45:00"
transactionFlow="false"
transferMode="Buffered"
transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard"
listenBacklog="10"
maxBufferPoolSize="2147483647"
maxBufferSize="2147483647"
maxConnections="10"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
<reliableSession ordered="true"
inactivityTimeout="05:45:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign"/>
</security>
</binding>
</netTcpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
<system.webServer>
<modules runAllManagedModulesForAllRequests="true"/>
</system.webServer>
Really appretiate any feedback or suggesttion. Also what is the recommended settings on F5 when used WCF with NetTcpBinding.
I got it working now. It was Load Balance configuration issue. We have changed the Virtual Server type from Standard to Performance (Layer 7). The performance is not improved to acceptable range.
Related
We have design AJAX – Enable WCF web services for our mobile application. Web service methods returns data in JSON format. We are observing delay in calling web services and binding it to mobile widget. The size of data in approximately 50K.
According to Code Project , we have applied changes to web.config file of WCF Web Service.
Similarly, following one of the stackoverflow question we are trying to increase message size. Now, problem is how we should apply changes to our current web.config file so that message size is increase. We are using default NET 4.0 setting. Also, do we need to define end point on our client web.config file. Can someone provide client side web.config?
Our current server web.config settings is:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0" />
<identity impersonate="false" />
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
</system.web>
<system.serviceModel>
<diagnostics performanceCounters="All"></diagnostics>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<!--Increase WCF Performance-->
<serviceThrottling maxConcurrentCalls="100" maxConcurrentInstances="100" maxConcurrentSessions="100"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="MobileService.webHttpBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
<!--Increase WCF Performance-->
<bindings>
<basicHttpBinding>
<binding name="basicHttp" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32" maxArrayLength="20000000" maxStringContentLength="20000000"/>
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="MobileWCFService.Service1" behaviorConfiguration="ServiceBehavior">
<endpoint address="" binding="webHttpBinding" contract="MobileWCFService.Service1" behaviorConfiguration="MobileService.webHttpBehavior" />
</service>
</services>
</system.serviceModel>
</configuration>
Can anyone confirm if changes I applied is valid or not and mark it has confirm answers?
<system.serviceModel>
<diagnostics performanceCounters="All"></diagnostics>
<behaviors>
<endpointBehaviors>
<behavior name="MobileService.webHttpBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
<!--Increase WCF Performance-->
<serviceThrottling maxConcurrentCalls="100" maxConcurrentInstances="100" maxConcurrentSessions="100"/>
</behavior>
</serviceBehaviors>
</behaviors>
<!--Increase WCF Performance-->
<bindings>
<webHttpBinding>
<binding name="webHttp" allowCookies="true" maxReceivedMessageSize="20000000" maxBufferSize="20000000" maxBufferPoolSize="20000000">
<readerQuotas maxDepth="32" maxArrayLength="20000000" maxStringContentLength="20000000"/>
</binding>
</webHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="MobileWCFService.Service1" behaviorConfiguration="ServiceBehavior">
<endpoint address="" binding="webHttpBinding" contract="MobileWCFService.Service1" behaviorConfiguration="MobileService.webHttpBehavior" bindingConfiguration="webHttp" />
</service>
</services>
I am trying to decide on an architecture for a change in my web service. I need to make a WCF service. I want to make only one service and then host it either in the IIS or in a Windows service. Is this even possible, making this kind of reuse of a WCF Service? How would I go about doing this? The scenario is that some of our customers do not have access to start a Windows service but can install a WCF in the IIS.
Thank you in advance.
A WCF service is simply an assembly that abides by the WCF hosting interface and then provides a client interface that allows it to be accessed.
Hosting a WCF service occurs equally in IIS, Windows service, WinForm application, or a console application. It truly doesn't matter.
The client interface remains unchanged, although how the interface is exposed might change depending on hosting scenario. For example, you'll probably use one the http bindings in the IIS case, but might use TCP binding for Windows services. These bindings can be defined in the config file, so the code doesn't necessarily have to change to accommodate being hosted one way or the other.
In short, creating the WCF service should be independent of how it will eventually be hosted. For ease of maintenance on your part, though, I'd pick one or the other - Windows service or IIS.
you could have a windows service host the WCF and expose all end points on it..Http,TCP..
Windows service is better than IIS because IIS is a process in itself and then we place upon it a VD to host our website/WCF.As for the Windows Service,it will be one dedicated thread catering only to the WCF.I am sharing the app.config of windows service (details changed) to show how we have hosted WCF...hope it helps..
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="Off" propagateActivity="true" >
<listeners>
<add name="SERVICE_MONITOR" type="System.Diagnostics.XmlWriterTraceListener"
initializeData="MyApp_MONITOR.svclog" />
</listeners>
</source>
<source name="MyApp_TRACE" switchValue="All" >
<listeners>
<add name="MyApp_TRACE_LISTENER" type="System.Diagnostics.XmlWriterTraceListener"
initializeData="MyApp_TRACE.svclog" />
</listeners>
</source>
</sources>
<trace autoflush="true" />
</system.diagnostics>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="OverAllServiceBehavior">
<serviceSecurityAudit
auditLogLocation="Application"
serviceAuthorizationAuditLevel="Failure"
messageAuthenticationAuditLevel="Failure"
suppressAuditFailure="true" />
<serviceDebug includeExceptionDetailInFaults="True" />
<serviceMetadata httpGetEnabled="True" httpsGetEnabled="True" />
<serviceThrottling maxConcurrentCalls="10000" maxConcurrentSessions="10000"
<dataContractSerializer maxItemsInObjectGraph="2147483647"/>
<serviceCredentials>
<userNameAuthentication
userNamePasswordValidationMode="Custom"
customUserNamePasswordValidatorType="MyAppHost.Authenticate, MyAppHost"/>
<serviceCertificate findValue="MyApp_MESSAGE" storeLocation="LocalMachine"
storeName="My" x509FindType="FindBySubjectName" />
<clientCertificate>
<authentication
certificateValidationMode="PeerTrust"
trustedStoreLocation="LocalMachine" />
</clientCertificate>
</serviceCredentials>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="OverAllEndPointBehavior" />
</endpointBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="ServiceBasicHttpEndPointBinding" closeTimeout="00:00:59"
openTimeout="00:00:59"
messageEncoding="Text"
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="Message">
<message clientCredentialType="Certificate"/>
</security>
</binding>
</basicHttpBinding>
<wsHttpBinding>
<binding name="ServiceWSHttpEndPointBinding" closeTimeout="00:00:59"
openTimeout="00:00:59"
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="None" />
<message clientCredentialType="Certificate"/>
</security>
</binding>
</wsHttpBinding>
<netTcpBinding>
<binding name="ServiceTCPEndPointBinding" maxBufferSize="2147483647"
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
maxNameTableCharCount="2147483647" />
<security mode="TransportWithMessageCredential">
<transport
clientCredentialType="Certificate"
protectionLevel="EncryptAndSign" />
<message clientCredentialType="UserName" algorithmSuite="TripleDes"/>
</security>
</binding>
</netTcpBinding>
</bindings>
<services>
<service behaviorConfiguration="OverAllServiceBehavior"
name="MiddleWare.ServiceClasses.ServiceClass">
<host>
<baseAddresses>
<add baseAddress="net.tcp://127.0.0.1:15010/ServiceTCPEndPointMEX"/>
<add baseAddress="http://127.0.0.1:15020/ServiceHttpEndPointMEX"/>
<add baseAddress="https://127.0.0.1:15030/ServiceWSHttpEndPointMEX"/>
</baseAddresses>
</host>
<endpoint address="net.tcp://127.0.0.1:15040/ServiceTCPEndPoint"
contract="MiddleWare.ServiceContracts.IServiceContract" />
<endpoint address="http://127.0.0.1:15050/ServiceBasicHttpEndPoint"
contract="MiddleWare.ServiceContracts.IServiceContract"/>
<endpoint address="https://127.0.0.1:15060/ServiceWSHttpEndPoint"
contract="MiddleWare.ServiceContracts.IServiceContract"/>
<endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
</system.serviceModel>
<appSettings>
<add key="UserName" value="USER"/>
<add key="Password" value="PASSWORD"/>
</appSettings>
</configuration>
I've created and tested WCF service, everything works fine.
When I deployed to TEST environment and tried to open https://my.site/myapp/EnrollmentService.svc I've got the error message:
Could not find a base address that
matches scheme http for the endpoint
with binding
MetadataExchangeHttpBinding.
Registered base address schemes are
[https].
Internet showed me that I need to add some more configuration options:
http://www.codeproject.com/KB/WCF/7stepsWCF.aspx
I've added some settings to service web.config file. Now it looks like in the following way:
<system.serviceModel>
<services>
<service name="McActivationApp.EnrollmentService" behaviorConfiguration="McActivationApp.EnrollmentServicBehavior">
<endpoint
address="https://my.site/myapp/EnrollmentService.svc"
binding="basicHttpBinding"
bindingConfiguration="TransportSecurity"
contract="McActivationApp.IEnrollmentService"/>
<endpoint address="mex" binding="mexHttpBinding" contract="McActivationApp.IEnrollmentService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="McActivationApp.EnrollmentServicBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
Actually, I've added "bindings" section and specified it for my endpoint.
But this changed nothing...
Please advise, what I need to do. Thanks a lot!
P.S. Are there any differences in WCF service consuming from https and http resources?
When you want to expose your service only over HTTPS (site does not support HTTP at all) you can't use anything that is dependent on HTTP. Your current configuration exposes help page on HTTP and also mex endpoing (with wrong contract) on HTTP. So try this:
<system.serviceModel>
<services>
<service name="McActivationApp.EnrollmentService" behaviorConfiguration="McActivationApp.EnrollmentServicBehavior">
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="TransportSecurity" contract="McActivationApp.IEnrollmentService"/>
<endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="McActivationApp.EnrollmentServicBehavior">
<serviceMetadata httpsGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<basicHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport">
<transport clientCredentialType="None" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
</system.serviceModel>
You have got http metadata endpoint that should be changed to https as below.
<serviceMetadata httpsGetEnabled="True"/>
Also if not necessary you should remove the mex and https metadata endpoint from production as a best practice.
To fix the problem by allowing HTTP, you need to add a http binding in IIS:
Navigate to your site in IIS
Click 'Bindings...' in the Actions panel on the right.
Click 'Add'
Select 'http' and OK out.
Alternatively, you can prevent the problem by either deleting the line, or changing:
<serviceMetadata httpGetEnabled="True"/>
to:
<serviceMetadata httpsGetEnabled="True"/>
I'm trying to deploy a WCF-service, but I'm having dificulties getting the final bits to work. I'm not a deployment guru in any way, so please bear with me.
I'm using a WebHttpBinding to make Ajax calls to the service using JSON, but I receive the error: "Could not find a base address that matches scheme http for the endpoint with binding WebHttpBinding. Registered base address schemes are [].".
Here is a snippet of my web.config:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true">
<baseAddressPrefixFilters>
<add prefix="http://mysite.com/" />
</baseAddressPrefixFilters>
</serviceHostingEnvironment>
<bindings>
<webHttpBinding>
<binding name="webHttp">
<security mode="None">
<transport clientCredentialType="None"
proxyCredentialType="None"
realm="string" />
</security>
</binding>
</webHttpBinding>
</bindings>
<services>
<service name="LicenseManager.LicenseService" behaviorConfiguration="ServiceAspNetAjaxBehavior">
<endpoint address="" behaviorConfiguration="AjaxBehavior"
binding="webHttpBinding" contract="LicenseManager.ILicenseService" />
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="http://mysite.com/" />
</baseAddresses>
</host>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="AjaxBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceAspNetAjaxBehavior">
<serviceMetadata httpGetEnabled="true" httpGetUrl="" />
<serviceDebug httpHelpPageEnabled="true" includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
I've made so many changes and tried so many options that I honestly lost overview of what I'm doing. I hope you can find that tiny error that make it all work.
Thank you.
Is your site running directly under http://mysite.com, or is it running under an application/vdir under that site? If so, add the application in your <baseAddressPrefixFilter> element:
<baseAddressPrefixFilters>
<add prefix="http://mysite.com/MyApplication" />
</baseAddressPrefixFilters>
I don't think you need the trailing / either - but I don't think that's causing the issue.
Hopefully this helps! Let em know and I'll update my answer accordingly.
The error was caused by a silly mistake made by me.
My DNS was not set up yet, so I used GoDaddy's "Preview DNS" feature that lets me view the website before the DNS is set up. I used the preview address (mydomain.com.previewdns.com) when I should just have used mydomain.com.
My bad, thanks for the help!
I have a WCF based service that I use to expose AJAX functionality. Sometimes the service fails when I start a new debugging session (even if I make no changes to the service itself). A rebuild all fixes the issue. I never have this issue in production, just while debugging. I use IIS 7 to debug and have disabled all recycling. Below is my config.
Does anyone know why this happens? Is there another way I can configure the service?
Thanks!
Jon
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="SomeService.MyAjaxServiceAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<services>
<service name="SomeService.MyAjaxService">
<endpoint address="" behaviorConfiguration="SomeService.MyAjaxServiceAspNetAjaxBehavior" binding="webHttpBinding"
bindingConfiguration="webBinding"
contract="SomeService.MyAjaxService" />
<endpoint address="" behaviorConfiguration="SomeService.MyAjaxServiceAspNetAjaxBehavior" binding="webHttpBinding"
bindingConfiguration="sslWebBinding"
contract="SomeService.MyAjaxService" />
</service>
</services>
<bindings>
<webHttpBinding>
<binding name="sslWebBinding">
<security mode="Transport">
</security>
</binding>
<binding name="webBinding">
<security mode="None">
</security>
</binding>
</webHttpBinding>
</bindings>
</system.serviceModel>
I ended up having to add batch="false" in the web config. I still need to investigate the full ramifications of this, but at least I don't have to rebuild the service all the time.
Cheers,
Jon