views:

714

answers:

1

... the message contains an invalid expired security context token or because there is a mismatch between bindings...

The problem is, the client and the server times are a few seconds off. The web services all work fine, unless the call is made in between the few seconds that the client/server are off. So, if the call is made, and the client time is 6:00:58, and the server time is 6:01:01, the error above occurs.

I have added code to catch the exception, and try the call again, but keep getting this message.

I have synced the times on client/server, but they eventually get out of sync be a few seconds.

Does anyone have any ideas?

Here is part of the web config that matters (everything between client/server is same) :

  <service behaviorConfiguration="WebServiceBehavior" name="WebService.TestService">
    <endpoint 
  address="" 
  binding="wsHttpBinding" 
  bindingConfiguration="WSHttpBinding_Service" 
  contract="WebService.ITestService">
    </endpoint>
    <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="./WebService/TestService/" />
      </baseAddresses>
    </host>
  </service>    

</services>
<bindings>

  <wsHttpBinding>
    <binding name="WSHttpBinding_Service" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="1000000" maxReceivedMessageSize="1000000" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="false" allowCookies="false">
      <readerQuotas maxDepth="900000" maxStringContentLength="900000" maxArrayLength="900000" maxBytesPerRead="900000" maxNameTableCharCount="900000" />
      <reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
      <security mode="Message">
        <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
        <message clientCredentialType="Windows" negotiateServiceCredential="true" algorithmSuite="Default" establishSecurityContext="true" />
      </security>
    </binding>
  </wsHttpBinding>

</bindings>   

 <behaviors>
    <serviceBehaviors>
      <behavior name="WebServiceBehavior">
     <serviceMetadata httpGetEnabled="true" />
        <serviceDebug includeExceptionDetailInFaults="true" />
      </behavior>
    </serviceBehaviors>
  </behaviors>
</system.serviceModel>
<system.web>
    <customErrors mode="On" />
    <identity impersonate="false" />
    <authentication mode="Forms" />
</system.web>
+1  A: 

You can configure a custom binding that mimics wsHttpBinding that will let you increase the maxClockSkew on the security settings to be outside the error range. See this article. Too bad you can't do it directly on the existing wsHttpBinding.

nitzmahone