wcf service on load balance - c#

We have a windows application and it consumes WCF sevice and we use Network Load balancing.Sometimes clients could not connect to wcf service(server).
we use NetTcpBinding binding. Can anyone give me an idea to solve this issue.

Can you post your bindings here?
I would turn on tracing in your web service config to check that traffic is indeed reaching all your intended endpoints. NetTcpBinding pools TCP connections by default, so it could be that the client connection has associated itself to a specific server which is now not available. This would then mean that connections would start to fail. It is recommended that you tweak the default binding settings for NetTcpBinding when used in a load balanced scenario to reduce the lease timeout so that requests are load balanced better. http://msdn.microsoft.com/en-us/library/ms730128.aspx

Related

Should I disable WCF reliable sessions for Intranet scenarios?

The scenario is a web server in a DMZ that talks to a WCF server for all database related calls.
All calls are server to server in an intranet, either over netTcp or wsHttp from a ASPX page which calls an SVC service.
Theoretically speaking, should I take action to disable the reliable session features, or should I enable them, or would it make no difference?
It appears that reliable sessions introduces configuration risks (i.e. failures because WCF is so difficult to configure).
This is problematic if there never is a message that fails to go from one intranet server to the other, or if there never is an out-of-order message.
I wish I could load test this and monitor for the existence of dropped messages, but my available test environments are way different from the production environment with respect to network reliability.
Note: The users are not using WCF clients, they are just using ordinary web browsers talking to an ASPX page, all WCF activity is on the intranet side of the firewall.
According to msdn:
If your scenario has any of the following characteristics, then you should consider using a WCF reliable session:
SOAP intermediaries, such as SOAP routers.
Proxy intermediaries or transport bridges.
Intermittent connectivity.
Sessions over HTTP.
I think it doesn't make sense whether intranet or DMZ, so it depends on your requirement.

There was no endpoint listening at Error sometimes

I have hosted my WCF webs services into public server and consumed this service from the WPF application and this app is using around 2500 users for the Login purpose.Most of the time it is working fine. But in some case it gives the following error.
“Error : There was no endpoint listening at …….. that could accept
the message. This is often caused by an incorrect address or SOAP
action”
Any idea why this is happening sometimes. How can I solve this issue? Is it related to port was busy that time?
Thanks in Advance,
You may want to consider monitoring performance counters for your WCF service.
WCF has built-in performance counters that show system metrics associated with WCF Service throttling and security, in addition to the typical Windows counters (cpu, memory, etc.)
To enable performance counters, include <diagnostics performanceCounters="All"/>
in the <system.serviceModel> section of the WCF Service configuration file.
You can then add counters for “ServiceModel” at the Endpoint, Operation and/or Service level.
The following link provides additional information:
http://blogs.microsoft.co.il/idof/2011/08/11/wcf-scaling-check-your-counters/
Good luck.

Does WCF NetTcpBinding provide a persistent connection?

Making a client/server style app using WCF, but I can't find any documentation that explains if the NetTcpBinding provides a persistent connection?
I would like my client to connect and remain connected to the server for weeks at a time. (Yes I know I need to handle disconnects etc..)
Does the NetTcpBinding allow for a long connection such as this? If so is there anything I need to specify or is this default behaviour?
As long as you keep the service host and client proxy alive and opened, the underlying connection in WCF should remain opened as well. Even below that, it appears that the binding uses connections from the TCP connection pool, as found on the NetTcpBinding MSDN page:
The NetTcpBinding uses TCP connection pooling based on the service’s host DNS name and the port number the service is listening on.
I'm not an expert on how TCP connection pooling works, you may want to try a sister site such as ServerFault for more details on this.
If you want control over all this, then the only property I can see that can be tweaked for the out-of-the-box NetTcpBinding is MaxConnections. However, if you're really willing to dive deep you can also build your own Custom Binding with a TcpTransportBindingElement, that gives you even more fine-grained control on the TcpConnectionPoolSettings.
In any case, if I were to venture a guess I'd think building the service host and client proxy will take far more time (relatively) than any time spent getting a connection from the pool, so keeping those two opened may be enough for your requirements.
The reason I asked in a comment why you want the connection to remain open is because that can hardly be a requirement in itself. Speed and response times are a real requirement though, so the best advice is probably to make those requirements explicit (quantify / qualify your need for speed) and run some tests to determine what's best/needed for your situation.

WCF Service Hosted in Windows Service over net tcp

In my project I have one WCF Service which is hosted in a Windows Service. I hosted the WCF Service in Windows Service over netTCPBinding and Installed Windows Service. To access WCF service in my silverlight project I have added service reference of wcf.
But, when I am calling a method in WCF Service am getting the following error :
Could not connect to
net.tcp://localhost:8732/WCFHost/.
The connection attempt lasted for a time
span of 00:00:03.2951885.
TCP error code 10013: An attempt was made to
access a socket in a way forbidden by
its access permissions..
This could be
due to attempting to access a service
in a cross-domain way while the
service is not configured for
cross-domain access. You may need to
contact the owner of the service to
expose a sockets cross-domain policy
over HTTP and host the service in the
allowed sockets port range 4502-4534.
Please help me out.
For same-machine connections rather make use of Named Pipe bindings.
It might help if you showed us your service and client side endpoint configurations.
EDIT: After reading up a bit on the error you're getting (here among other sites), try changing the port number from 8732 to something between 4502-4534 as the error message suggests.
Keep same protocols at both the server and client end. May be your are calling the service with different protocols. Also check if your are using nettcp, your are having access to the machine where service is hosted.
use basicHttpBinding instead of netTCPBinding

WCF: "Failed to open System.ServiceModel.Channels.ClientReliableDuplexSessionChannel"

I currently have a WCF Service with a CallBack Contract (duplex), and when I use the application that makes use of it on my computer everything works fine, but when I try it from a different computer, it doesn't connect.
These problems started occurring once I switched to using this wsDualHttpBinding (for callbacks) because when I used wsHttpBinding everything worked fine.
Why is the web service not accepting requests from other computers? Is it some hosting settings that need to be modified?
As regards the logs, I am getting these:
alt text http://img17.imageshack.us/img17/4628/wcfissue.jpg
The open operation did not complete
within the allotted timeout of
00:01:00. The time allotted to this
operation may have been a portion of a
longer timeout
Failed to open System.ServiceModel.Channels.ClientReliableDuplexSessionChannel
Faulted
System.ServiceModel.Channels.ClientReliableDuplexSessionChannel
Faulted
System.ServiceModel.Channels.ServiceChannel
Failed to open
System.ServiceModel.Channels.ServiceChannel
The port is open on my router (both TCP and UDP) so that is not the issue.
As regards the Service Attributes, this is what I'm using:
Interface:
[ServiceContract(Name = "MusicRepo_DBAccess_Service",
CallbackContract = typeof(IOnlineUsersCallback),
SessionMode=SessionMode.Required)]
Service:
[ServiceBehavior(
ConcurrencyMode=ConcurrencyMode.Reentrant,
InstanceContextMode=InstanceContextMode.Single)]
[Update]
As regards Orion Edwards' post:
No Firewall
See point 1
Yes I can, because I have the port forwarded on my router
I'm using IIS to host the server.
The thing is, this problem started happening when I switched from wsHttpBinding (which was working fine) to wsDualHttpBinding (because I needed callbacks)
[Update]
I have now switched from wsDualHttpBinding to NetTcpBinding and for some reason, everything is working fine.
I have used this article to help me set up hosting on IIS, and thankully everything is working as expected, with callbacks.
I have now switched from wsDualHttpBinding to NetTcpBinding and for some reason, everything is working fine.
I have used this article to help me set up hosting on IIS, and thankully everything is working as expected, with callbacks.
It would help if you posted the server and client configuration settings.
Here's a summary of how the wsDualHttpBinding works from MSDN (emphasise mine):
The WSDualHttpBinding provides the
same support for Web Service protocols
as the WSHttpBinding, but for use with
duplex contracts. WSDualHttpBinding
only supports SOAP security and
requires reliable messaging. This
binding requires that the client has a
public URI that provides a callback
endpoint for the service. This is
provided by the clientBaseAddress
attribute. A dual binding exposes the
IP address of the client to the
service. The client should use
security to ensure that it only
connects to services it trusts.
This binding can be used to
communicate reliably through one or
more SOAP intermediaries.
By default, this binding generates a
runtime stack with
WS-ReliableMessaging for reliability,
WS-Security for message security and
authentication, HTTP for message
delivery, and a Text/XML message
encoding.
Things to check:
Windows Firewall
Your antivirus product's firewall
Can you telnet into the port from a remote machine?
Is your "server" running under the ASP.NET development server? That will only accept requests from localhosts - you need to self-host the server using ServiceHost or host it under IIS.

Categories