Intermittent WCF timeout issue - wcf

Client is frequently experiencing the following error
Additional information: Client is unable to finish the security negotiation within the configured timeout (00:00:00). The current negotiation leg is 1 (00:00:00).
This suggests somewhere I'm specifying a timeout period of 0 seconds which I am not. The binding in question I've explicitly set a timeout for 15 seconds
<ws2007HttpBinding>
<binding name="wsUsername" sendTimeout="00:00:15" receiveTimeout="00:00:15">
<security mode="TransportWithMessageCredential">
<message establishSecurityContext="false"
negotiateServiceCredential="true"
clientCredentialType="UserName" />
</security>
As I said it is quite intermittent. Quite a lot of the time this works and once it does work it continues to do so for 15 minutes or so until the failures start again. I've turned on WCF tracing but it doesn't tell me anything more than I'm conveying here.

Related

WCF: Single operation fails with MessageSecurityException

So what we have here is a fairly trivial WCF service with a bunch of operations. Now, all but one operation work just fine, but that single one fails with MessageSecurityException.
This particular method is just like any other method in this particular service: no fancy authentication or authorization attributes, no impersonation, no nothing. Just plain hit-the-DB-and-return-results kind of method. Security is set up as follows:
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
Yet whenever it gets invoked, it fails with
The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate,NTLM'
I know this is a very open-ended question, but I hope someone has experienced the same.

Page crahses if repsonse time is more

Im using Silverlight with wcf for my application. When the page requests it goes to the service for the output. But if the response(database operation) takes a bit of time to provide the output then my silverlight page is getting crashed. Can any help me what is the problem.
Sounds like you need to set the timeout settings for the WCF service to be higher to cater for the potential delays. The timeout settings are usually set in the bindings defined in the
<system.serviceModel>
<bindings>
section of the config file.
You will need to make sure that the 'receiveTimeout' in the client config, and the 'sendTimeout' in the service config are set to appropriate values that are high enough to cater for your particular service's timings.
An example 'basicHttpBinding' for the client-side, with a 'receiveTimeout' of 1 minute, 30 seconds could look like this (the important item to note being the 'receiveTimeout'):
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBindingConfig" receiveTimeout="00:1:30">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>

Disable Windowsauthentication WCF

I'm using WCF to create a Client-Server Application and I'm having some problems with authentication, with wsHttpBinding Windowsauthentication seems to be turned on by default. The webservice worked perfectly inside my network but when I installed it somewhere else I suddenly had all these securityexceptions.
Though I want the webservice to be encrypted with https, i dont want windows authentication.
Although I can't try it at the moment I've found this Configuration:
<security mode="Transport">
<transport clientCredentialType="Certificate" />
</security>
Which might do the trick. This is my "old" one:
<security mode="Message">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" />
</security>
This is the configuration on the client side which i dont quite understand cause anybody could just change this easily. I'd expect to configure this on the server side but i havent yet found out how.
Ideas?
You can disable it through IIS Authentication settings for the site hosting your WCF by turning it off there and leaving anonymous on.
http://technet.microsoft.com/en-us/library/cc754628(v=ws.10).aspx

SecurityMode.None leads to TimeoutException instead of CommunicationObjectFaultedException

I have a WCF self-hosted service with net.tcp binding.
I need it to be nonsecured with reliable session.
When I configure it to nonsecure all calls to closed service (close, crash, process kill - any reason) lead to timeout exceptions (hang for a minute and timeout). When default (mode = Transport) - I get CommunicationObjectFaultedException at the same moment, seems like infrastructure automatically determines connection break.
How can I get immediate CommunicationObjectFaultedException with nonsecured settings?
Server and client configs are ok. Everything works fine untill I change to nonsecured (of course I change server and client configs).
I've spent many hours to solve the problem, found some similar problems but no answer.
Server config:
<netTcpBinding>
<binding name="TCPBinding" receiveTimeout="Infinite">
<reliableSession enabled="true" inactivityTimeout="00:10:00"/>
<security mode="None">
</security>
</binding>
</netTcpBinding>

How could a WCF service become locked?

In my application a Winform UI thread in sync calls a WCF method.
99.99% of the time this is ok, but once in a while the call to the WCF method becomes locked and the UI freezes.
I know I can prevent the freezing of UI by making the call async - most of our WCF calls are async - but we considered it not so bad to make this particular tiny method in sync.
When the lock in the WCF service occurs other users cannot access the service as well. I have to restart the WCF service host (Windows service) to resolve the problem.
How is it possible for a WCF service to become locked and inaccessible?
I can't think of a scenario.
We checked the database, which was running as usual.
Technical details:
We use a proxy in a service agent. This service agent with its proxy is kept alive while the application runs.
[PreserveReferences]
[OperationContract(IsOneWay = false, AsyncPattern = false, Action = "MyMethod")]
MyType MyMethod();
The binding in use:
<wsHttpBinding>
<binding name="AppWsHttpBindingConfig" transactionFlow="true" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" messageEncoding="Mtom">
<readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
<reliableSession ordered="false" enabled="false" />
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
Most of the WCF service hang problems is related to disposal of WCF client proxies, which i believe is the problem in your case. If you are not disposing client proxies correctly you will get a timeout exception when you make the (maxConcurrentSessions + 1) n-th call.
Please check out this article.
Basically it says that, if your channel is not in a faulted state, calling Abort on that channel frees the client resources but does not free server resources. For example when a service method throws a FaultException it does not put the channel in a faulted state. So calling abort on this proxy will result in an open session in your server with no client.
Wheter this is your case or not, you should consider using the approach described in that article, or some other with the same idea.