WP8 client WCF service time difference

One of my projects is a Windows Phone application that enable homecare workers to get information about the patient they have to visit, report any problems with those clients and register the time they spend at those client.

One day I got “the panic call” from my contractor. At one of the organisations using this software, the more and more people couldn’t login (the app doesn’t display a specific error) so I started to investigate the problem. After some digging I found this error:

Security processor was unable to find a security header in the message.

That is weird, because that software works for most users, only 1 server (each organisation has it’s own server) has problems. After some google research I found that the problem might be a time-difference between the server and the client, the default maximum it 5 minutes. The server time was 10 minutes behind, when I adjusted the time of my WP7 phone I was able to connect.

How to solve this problem? Use a custom binding that sets the “maxclockskew” property, this is best done in the .config file of the service/client. On the server this looks like this:

 
<customBinding>
<binding name="customBindingLogin">
<security authenticationMode="UserNameOverTransport" messageSecurityVersion="WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10">
<localClientSettings maxClockSkew="01:30:00"/>
<localServiceSettings maxClockSkew="01:30:00"/>
<secureConversationBootstrap>
<localClientSettings maxClockSkew="01:30:00"/>
<localServiceSettings maxClockSkew="01:30:00"/>
</secureConversationBootstrap>
</security>
<textMessageEncoding/>
<httpsTransport />
</binding>
</customBinding>

On the client it looks like this:

 
<binding name="customBindingLogin">
<security authenticationMode="UserNameOverTransport" includeTimestamp="true">
<localClientSettings maxClockSkew="01:30:00" replayWindow="00:05:00" timestampValidityDuration="00:05:00" />
<secureConversationBootstrap />
</security>
<textMessageEncoding messageVersion="Default" writeEncoding="utf-8" />
<httpsTransport maxReceivedMessageSize="2147483647" maxBufferSize="2147483647" />
</binding>

When you use “update service reference”, most properties are missing in the client config, you have to add then manually.

Hope it helps you

 

Comments are closed.