Graph API Notification URL Validation time out

Simeon L 0 Reputation points
2023-05-08T17:50:14.37+00:00

Hello,

I am trying to set up a Subscription for chats/getAllMessages and I am encountering some very weird behavior. Upon logging in to my App and starting the subscription process, the Application hangs for 10 seconds followed by Graph API's "Subscription validation request timed out". Now the weirdness begins: instantly after the time-out message appears, my Application actually receives the Validation Request and attempts to process it.

The App is located on a publicly available VPS behind Cloudflare (currently set to DNS only so I can rule out Cloudflare being the Problem), doing the same Validation Request via Graph API's Postman Collection results in a sub-second response and 3 passing unit tests. (Collection -> Misc ->Subscription validation)

Below you can find the relevant Code Snippet that is used to process the request, it does include some debugging.

Like I said above, using Postman works absolutely perfect, also the endpoint is being called immediately after the timeout

    post("/notifyMessage") {
        NvrLogger.info("contains validationToken: ${call.request.queryParameters.contains("validationToken")}")
        if (call.request.queryParameters.contains("validationToken")) {
            NvrLogger.info("Plain: ${call.request.rawQueryParameters["validationToken"]}")
            val decodedToken = call.request.queryParameters["validationToken"]
            NvrLogger.info("decodedToken: $decodedToken")
            call.respondText(decodedToken.toString())
        }
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,592 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Antonio 250 Reputation points Microsoft Vendor
    2023-05-15T21:00:20.25+00:00

    Hi Simeon L,

    Thanks for posting in the Q&A forum. The time out duration of 10 seconds appears to indicate that Microsoft Graph did not receive a validation response within the expected time frame.

    Please verify/reference the following items:

    • See to isolating the code with Graph Explorer to call same API and observe results.
    • Note notificationUrl must be capable of responding to the validation request. Also, you need to make sure that the validation token returns as plain/text. Please refer to the Notification endpoint validation document for details.
    • Some mentions from that same reference:
      200 (OK) status code.
      content type must be text/plain.
      body must include the validation token.
    • Reference these code samples below to compare with source code in question:
    // Validate the new subscription by sending the token back to Microsoft Graph.  
    // This response is required for each subscription.  
    if (Request.QueryString["validationToken"] != null)  
    {  
       var token = Request.QueryString["validationToken"];  
       return Content(token, "plain/text");  
    }  
    

    Note also to verify (if applicable) that no other connection issues with the API gateway in use (i.e., AWS API Gateway) via custom domains.

    As it maybe, possible that an increase in of API Gateway increased over time. Which could potentially trigger some limitations of connections via MS Graph API to the API Gateway. For further troubleshooting using public webhook listener testing tools for reproduction of this issue.

    Please note currently known issues, otherwise for further investigations for specific account related issues.

    Please request via a support case using the links below:


    Please don't forget to upvote and Accept as answer if the reply is helpful

    0 comments No comments