Something interesting is happening. When I always supply the correct cookie it works on and off. One call works and the second gives 204 error. Third is good again and fourth error 204.
I adapted hc_responseSuccess as follows:
Log ("Status code: " & Response.StatusCode & TaskId)
Select Case Response.StatusCode
Case 204
'no user found
CompleteJob(TaskId, False, "Unauthorized",401)
Case Else
End Select
Response.GetAsynchronously("response", File.OpenOutput(TempFolder, TaskId, False), _
True, TaskId)
204 is raised when there is no content. I pass this to CompleteJob with success false and creating error 401.
I'm 100% sure if error is 204 that GetAsynchronously it not called at all. However, when called it seems the cookie creates something to that the next call fails.