Search code examples
.netdynamics-crm

Dynamics CRM SDK : Unsecured fault in the long run


I have a job written in C# that uses the Dynamics SDK 2016 to feed quite a lot of data into an on-premise Dynamics CRM. It's basically all OrgProxy.Create()'s and Associate's using the same OrganizationServiceProxy instance all the way. At first everything goes fine, but after an hour or so, every command I send fails with

an unsecured or incorrectly secured fault was received from the other party

Then if I stop and re-run the program immediately, it does the same thing all over again - work perfectly during the first hour but reject it all after.

I enabled the logs on the Dynamics server but they contain nothing relevant to that problem. I tried to delete or rename LiveDevice.xml as suggested in many places, but the file is nowhere to be found on my machine. Also looked at various CRM settings in IIS, Deployment Manager and the Dynamics interface proper - none seems to point to a specific timeout period or max connection time that would match my problem.

Has anyone experienced this or even have the vaguest idea why Dynamics would start complaining only after X amount of time ? All similar problems I have read about so far seem to fail right from the start.


Solution

  • An hour is pretty short, but I believe I've seen this in the past when running over night apps because the auth token expires (although I'm pretty sure there was a more descriptive error). Run fiddler and take a look at at the initial auth call to see what the expiration date is on the token coming back, specifically looking for something like the following:

    <trust:Lifetime>
        <wsu:Created xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            2016-08-12T13:08:20.839Z
        </wsu:Created>
        <wsu:Expires xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
            2016-08-13T13:08:20.839Z
        </wsu:Expires>
    </trust:Lifetime>
    

    If it is an hour from the issue timestamp then that might be your issue.