weixin_39548490
weixin_39548490
2021-01-01 16:54

BotFrameworkAdapter.processActivity(): 500 ERROR - Error: Unknown

Versions

SDK v4. NodeJS 10.15.2 Azure + MS Teams channel Windows

Describe the bug

Bot gives HTTP Error 500 while calling any of my dialogs. Application works great on Emulator. I found that it calls twice the Bot method: async onTurn(turnContext). I checked that https://github.com/Microsoft/botbuilder-js/issues/249 is not the case since I disconfigured QnA Maker and my LUIS quota is ok:

imagen

To Reproduce

Steps to reproduce the behavior: 1. MS Team Channel 2. Invoke any of the dialogs that prompts the user or shows more than 1 card 3. Bot throws this error twice:

[onTurnError]: Error: Unknown BotFrameworkAdapter.processActivity(): 500 ERROR - Error: Unknown (node:4468) UnhandledPromiseRejectionWarning: Error: Error: Unknown at BotFrameworkAdapter.processActivity (D:\home\site\wwwroot\node_modules\botbuilder\lib\botFrameworkAdapter.js:469:19) at process._tickCallback (internal/process/next_tick.js:68:7) (node:4468) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 10)

My dependencies are: "dependencies": { "axios": "^0.18.0", "botbuilder": "^4.2.0", "botbuilder-ai": "^4.3.4", "botbuilder-azure": "^4.3.4", "botbuilder-dialogs": "^4.3.4", "botframework-config": "^4.2.0", "dotenv": "^6.1.0", "fs": "0.0.1-security", "request-promise": "^4.2.4", "restify": "^7.2.3", "sp-request": "^2.1.3", "spsave": "^3.1.5" },

I suspect that when the bot needs to show more than 5 cards one after the other this error is thrown. With less than 6 cards sometimes isn't reproduced. And the only channel that is failing with is MS Teams. Cards could have images, or could be plain text.

I wonder how you would try to reproduce it. Do you want the Bot Id? Or one of the dialogs classes?

Expected behavior

This issue is not reproducible using local environment with same NodeJS version and the Emulator as is happening on Azure / MS Teams. I even tried the Web Channel as is not reproducible either.

[bug]

该提问来源于开源项目:microsoft/botbuilder-js

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

18条回答

  • weixin_39548490 weixin_39548490 4月前

    Here's the pattern for every broken dialog transaction. It's seen duplicate below and ends with a HTTP 429 at the end:

    imagen

    I believe this must be related to, which this is not the cause, it's the consequence of: https://docs.microsoft.com/en-us/microsoftteams/platform/resources/general/rate-limit

    点赞 评论 复制链接分享
  • weixin_39849153 weixin_39849153 4月前
    • Can you go ahead and tell me what botbuilder version you're using?
    点赞 评论 复制链接分享
  • weixin_39548490 weixin_39548490 4月前

    Finally, I could make the MS Teams channel work only if I introduce a sleep of 500 ms between every await stepContext.context.sendActivity() calls. This is definately related with specific Teams channel rate limits. The botAdapter should we trapping the trace of the HTTP 429.

    Could you please advise what that rate is?

    点赞 评论 复制链接分享
  • weixin_39849153 weixin_39849153 4月前
    • Are you seeing the posts where I'm asking you what botbuilder version you're using? You can use npm list to check the versions of all your packages.
    点赞 评论 复制链接分享
  • weixin_39548490 weixin_39548490 4月前

    Hi -kydela, I'm using botbuilder v4.3.4. Thanks for your support. Sure, I will workaround it adding a sleep time between cards of 500 ms.

    +-- botbuilder.3.4 | +-- /filenamify.0.2 | | -- filenamify.1.0 deduped | +-- /node.14.4 | +-- async-file.0.2 | |-- rimraf.6.3 | | -- glob.1.3 deduped | +-- botbuilder-core.3.4 | | +-- assert.4.1 | | |-- util.10.3 | | | -- inherits.0.1 | |-- botframework-schema.3.4 | +-- botframework-connector.3.4 | | +-- /ms-rest-js.2.6 | | | +-- axios.18.0 deduped | | | +-- form-data.3.3 deduped | | | +-- tough-cookie.5.0 deduped | | | +-- tslib.9.3 | | | +-- uuid.3.2 deduped | | | -- xml2js.4.19 | | | +-- sax.2.4 | | |-- xmlbuilder.0.7 deduped | | +-- /jsonwebtoken.2.8 | | | -- /node.14.4 deduped | | +-- /node.14.4 deduped | | +-- base64url.0.1 | | +-- botframework-schema.3.4 deduped | | +-- form-data.3.3 | | | +-- asynckit.4.0 | | | +-- combined-stream.0.7 deduped | | |-- mime-types.1.22 deduped

    点赞 评论 复制链接分享
  • weixin_39849153 weixin_39849153 4月前

    Hmm, that's interesting that you're still getting the issue in 4.3.4 and I'm not. In any case, I don't know that there's any specific rate you need to use, since the issue is so inconsistent. 500 ms is probably long enough, but my recommendation is still to just send fewer messages. Since you seem to be satisfied with your workaround, I will close this issue now. Thank you for posting!

    点赞 评论 复制链接分享
  • weixin_39994665 weixin_39994665 4月前

    Hey, we are somehow facing similar issue right now. We are getting "429 Too many Requests". This was working fine previously. Just started causing errors in 2 days.

    点赞 评论 复制链接分享
  • weixin_39548490 weixin_39548490 4月前

    Hi , the issue is not solved, you´ll need to slow down the load of messages that the bot answers. I made a workaround invoking a sleep function with 500+ ms among messages to stop receiving that error. async sleep(millis) { return new Promise(resolve => setTimeout(resolve, millis)); }

    点赞 评论 复制链接分享
  • weixin_39568597 weixin_39568597 4月前

    Hello! Is there any update in this issue, I am facing the same error in facebook channel. It was actually working just yesterday and now facebook won't send the bot the "name" of user who messaged the bot. Thanks!

    点赞 评论 复制链接分享
  • weixin_39568597 weixin_39568597 4月前

    hey -kydela , the bot was working fine now. To be clear, I didn't do any changes in the bot, but today it miraculously changed to its normal operations. I just have to ask if there was some changes in the bot channels at that time? If so, where can we have real time updates about these changes, (as some of it might cause major business impact). Thanks!

    And in response to the Graph API question in stackoverflow. See this https://developers.facebook.com/docs/graph-api/reference/user/ where I just used the curl to get last name, first name and profile picture of the user. Thanks!

    点赞 评论 复制链接分享
  • weixin_39548490 weixin_39548490 4月前

    Inspecting App Insights transaction logs I found HTTP 429:

    imagen

    Inspecting the User Flow:

    imagen

    点赞 评论 复制链接分享
  • weixin_39849153 weixin_39849153 4月前
    • Actually, I've changed my mind. I just tried updating to botbuilder 4.3.4 and the issue stopped occurring. Perhaps the bug has already been fixed. Please update your NPM packages and see what happens.
    点赞 评论 复制链接分享
  • weixin_39548490 weixin_39548490 4月前

    I enabled appinsights for the bot. I send one message to the bot using Teams that invokes a dialog. That is seen as two requests on the graph, whereas if I send same message using Azure Web Chat it's logged correctly as only one request:

    imagen

    点赞 评论 复制链接分享
  • weixin_39849153 weixin_39849153 4月前
    • What type of card are they? Are the cards being sent in the same message or separate messages?
    点赞 评论 复制链接分享
  • weixin_39548490 weixin_39548490 4月前

    They are separate thumbnail cards:

    node
    function createThumbnailCardAnonymousCaseStudies(url, title, mimeType) {
        var thumbnailImage = thumbnailImageIcon(mimeType);
        return CardFactory.thumbnailCard(
            title,
            CardFactory.images([process.env.AZURE_STORAGE_HOST + "/icons/" + thumbnailImage]),
            CardFactory.actions([
                {
                    type: 'openUrl',
                    title: "File Link",
                    value: url
                }
            ]),          
        );
    }
    
    node
    for (var i = 0; i < sharepointFiles.length; i++) {
        var card = globalEntities.createThumbnailCardAnonymousCaseStudies(
            longFolder + sharepointFiles[i],
            sharepointFiles[i],
            globalEntities.getFileExtension(sharepointFiles[i])
        );
    
        await turnContext.sendActivity({ attachments: [card] });
    }
    

    And even doing multiple (more than 5 or 6):

    await turnContext.sendActivity("some text");

    the error is thrown.

    点赞 评论 复制链接分享
  • weixin_39849153 weixin_39849153 4月前
    • Just to make sure I'm understanding you correctly, are you saying the error occurs even when you send a text-only activity with no attachments? So the error has nothing to do with cards?
    点赞 评论 复制链接分享
  • weixin_39548490 weixin_39548490 4月前

    Exactly, the error is more related to a channel issue (with Teams), rather than which content I send.

    点赞 评论 复制链接分享
  • weixin_39548490 weixin_39548490 4月前

    I'm invoking same dialogs on Azure Web Chat and on Teams. First works perfect, second doesn't.

    点赞 评论 复制链接分享