botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

Alternating Connection Test Results

Open hughcameron opened this issue 10 years ago • 4 comments

When testing the connection to my bot in the Bot Framework the results alternate between "Accepted" and "Forbidden: You do not have permission to view this directory or page."

The bot hosting is Azure - is there any way I can track down the source of the issue via the Bot Framework or should I raise a ticket with Azure?

hughcameron avatar Sep 27 '16 05:09 hughcameron

It sounds as if you have different pieces of code running across multiple machines. I don't think there is a way to track that down through the Bot Framework, since we don't have any useful information about which node behind an opaque load balancer responded to a request. You might consider redeploying your code or adjusting the instance count to 1 for temporary debugging.

willportnoy avatar Sep 27 '16 15:09 willportnoy

Hi @willportnoy - a bit of a delay in response here but testing has been ongoing! To provide some detail:

  • an auto-scale rule to create additional instances has been put in place but that rule has never been triggered
  • also, Application Request Routing in Azure has been enabled

For a period the errors were not appearing and the bot was approved for the Slack app directory. Just recently we received a message from a user indicating issues were still being received. This bot (Button.ai) traffics workflow between two or more Slack users. Expected bot behaviour is:

  • Step 1: User A sends the bot a direct message outlining a question for User B,
  • Step 2: The bot delivers the question to User B with reply buttons
  • Step 3: User B responds using one of the buttons

We’ve managed to isolate the issue to a 403 response that occurs on Step 3 from the web app hosted in Azure.

A failed Q&A answer looks like this:

Web server: 2016-10-11 05:45:50 BUTTONAI POST /api/messages X-ARR-LOG-ID=73b84827-649c-4371-8316-73ebcb3a695f 443 - 52.160.104.193 BF-Slack+(Microsoft-BotFramework/3.1++https://botframework.com/ua) - - buttonai.azurewebsites.net 202 0 0 339 2257 235
Web server: 2016-10-11 05:45:50 BUTTONAI POST /api/messages X-ARR-LOG-ID=15292080-dca8-4835-81fd-200b12aca8b0 443 - 52.160.104.193 BF-Slack+(Microsoft-BotFramework/3.1++https://botframework.com/ua) - - buttonai.azurewebsites.net 202 0 0 339 2449 281
Web server: 2016-10-11 05:46:01 BUTTONAI POST /api/messages X-ARR-LOG-ID=f3bb5305-3474-4a89-ab6e-d21890129dad 443 - 40.78.17.157 BF-Slack+(Microsoft-BotFramework/3.1++https://botframework.com/ua) - - buttonai.azurewebsites.net 403 0 0 424 4197 31

A successful Q&A looks like this:

Web server: 2016-10-11 06:00:19 BUTTONAI POST /api/messages X-ARR-LOG-ID=609ccb70-24d1-490c-b829-ed58e343c2b2 443 - 52.160.104.193 BF-Slack+(Microsoft-BotFramework/3.1++https://botframework.com/ua) - - buttonai.azurewebsites.net 202 0 0 339 2257 272
Web server: 2016-10-11 06:00:22 BUTTONAI POST /api/messages X-ARR-LOG-ID=8c0d8598-4427-434d-b9f6-36bff58f4365 443 - 52.160.104.193 BF-Slack+(Microsoft-BotFramework/3.1++https://botframework.com/ua) - - buttonai.azurewebsites.net 202 0 0 339 2459 224
Web server: 2016-10-11 06:00:33 BUTTONAI POST /slack/actions X-ARR-LOG-ID=95a6e7e1-5f04-4d59-a0a3-f782eda74626 443 - 52.91.184.228 Slackbot+1.0+(+https://api.slack.com/robots) - - buttonai.azurewebsites.net 200 0 0 746 2444 31
Web server: 2016-10-11 06:00:34 BUTTONAI POST /api/messages X-ARR-LOG-ID=35c105d2-2502-4ebd-91a8-c88727eddf7e 443 - 40.78.21.191 BF-Slack+(Microsoft-BotFramework/3.1++https://botframework.com/ua) - - buttonai.azurewebsites.net 202 0 0 339 4188 14

Any tips on why the 403 is being returned?

A review of the 403 instances in the Bot Framework repository suggest an incorrect App ID and App Secret might be the issue but we’ve double checked these. This 403 has us stumped!

hughcameron avatar Oct 11 '16 09:10 hughcameron

We found that if we hit your bot endpoint after a period of inactivity then the first request fails with a 403. But subsequent requests succeeds. This seems to indicate that some auth information might be timing out and not refreshing correctly.

Are you using the C# SDK? The SDK has a couple of traces that'll help debug this. They are

Trace.TraceError($"Error refreshing OpenId configuration: {e}"); Trace.TraceError("Error finding key for token. Available keys: " + keys);

Can you see if you can find one or both of these in your logs?

Thanks.

mingweiw avatar Oct 14 '16 21:10 mingweiw

@mingweiw thanks for that insight. After further tests, this issue stopped occurring on 14-October. We didn't make any changes so we're not 100% sure of the cause but we'll take it as fixed!

hughcameron avatar Oct 25 '16 05:10 hughcameron