question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: BotFrameworkAdapter.processActivity(): 401 ERROR

See original GitHub issue

Versions

botbuilder: 4.9.2 (Latest) node: 12.18.2 (Latest) OS: Ubuntu (Docker-Container)

Describe the bug

One of a sudden adapter.processActivity fails with these two error messages when sending a chat-message to the bot:

1. Error Message: JwtTokenExtractor.getIdentity:err! ReferenceError: XMLHttpRequest is not defined dev_server | at /var/huforce/node_modules/whatwg-fetch/dist/fetch.umd.js:484:17 ... dev_server | at /var/huforce/node_modules/botframework-connector/lib/auth/openIdMetadata.js:14:71 dev_server | at new Promise (<anonymous>) dev_server | at __awaiter (/var/huforce/node_modules/botframework-connector/lib/auth/openIdMetadata.js:10:12) dev_server | at OpenIdMetadata.getKey (/var/huforce/node_modules/botframework-connector/lib/auth/openIdMetadata.js:30:16) dev_server | at JwtTokenExtractor.<anonymous> (/var/huforce/node_modules/botframework-connector/lib/auth/jwtTokenExtractor.js:86:56)

2. Error Message: (node:18) UnhandledPromiseRejectionWarning: Error: BotFrameworkAdapter.processActivity(): 401 ERROR dev_server | ReferenceError: XMLHttpRequest is not defined dev_server | at /var/huforce/node_modules/whatwg-fetch/dist/fetch.umd.js:484:17 dev_server | at new Promise (<anonymous>) dev_server | at fetch (/var/huforce/node_modules/whatwg-fetch/dist/fetch.umd.js:477:12) dev_server | at OpenIdMetadata.<anonymous> (/var/huforce/node_modules/botframework-connector/lib/auth/openIdMetadata.js:54:31) dev_server | at Generator.next (<anonymous>) dev_server | at /var/huforce/node_modules/botframework-connector/lib/auth/openIdMetadata.js:14:71 dev_server | at new Promise (<anonymous>) dev_server | at __awaiter (/var/huforce/node_modules/botframework-connector/lib/auth/openIdMetadata.js:10:12) dev_server | at OpenIdMetadata.refreshCache (/var/huforce/node_modules/botframework-connector/lib/auth/openIdMetadata.js:53:16) dev_server | at OpenIdMetadata.<anonymous> (/var/huforce/node_modules/botframework-connector/lib/auth/openIdMetadata.js:34:32) dev_server | at Generator.next (<anonymous>) dev_server | at /var/huforce/node_modules/botframework-connector/lib/auth/openIdMetadata.js:14:71 dev_server | at new Promise (<anonymous>) dev_server | at __awaiter (/var/huforce/node_modules/botframework-connector/lib/auth/openIdMetadata.js:10:12) dev_server | at OpenIdMetadata.getKey (/var/huforce/node_modules/botframework-connector/lib/auth/openIdMetadata.js:30:16) dev_server | at JwtTokenExtractor.<anonymous> (/var/huforce/node_modules/botframework-connector/lib/auth/jwtTokenExtractor.js:86:56) dev_server | at BotFrameworkAdapter.<anonymous> (/var/huforce/node_modules/botbuilder/lib/botFrameworkAdapter.js:674:27) dev_server | at Generator.throw (<anonymous>) dev_server | at rejected (/var/huforce/node_modules/botbuilder/lib/botFrameworkAdapter.js:12:65) dev_server | at processTicksAndRejections (internal/process/task_queues.js:97:5)

Details

I created my bot via the App-Studio. I don’t have an azure subscription. I neither use the emulator. The bot runs locally. I am using ngrok to tunnel the requests to my PC.

What I have tried

  • I tried various versions of your (awesome) package
  • I checked the client-id & the client-secret
  • I created a new client-secret
  • I verified my client-id & my client-secret
  • I checked my messaging endpoint
  • I verified the system time
  • I created a new bot via the App Studio and the https://dev.botframework.com
  • Installing xmlhttprequest manually

Code:

` … const bot = new Bot(); export const adapter = new BotFrameworkAdapter({ appId: msteams.CLIENT_ID, appPassword: msteams.CLIENT_SECRET }); MicrosoftAppCredentials.trustServiceUrl( “https://smba.trafficmanager.net/emea/” ); … expressApp.post(“/bot”, secure((req, res) => { adapter.processActivity(req, res, async context => { // <-- error await bot.run(context); }); }));

`

I am desperate, because we need to deliver a new version of our bot. But, I just can’t fix this issue. I really appreciate any help.

[bug]

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:18 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ace-kay-law-neocommented, Jul 15, 2020

Ok, I now know how to fix the error. But it is extremely strange.

Error: … const expressApp = express();

import botbuilder from “botbuilder”; const { BotFrameworkAdapter } = botbuilder; …

No Error: … import botbuilder from “botbuilder”; const { BotFrameworkAdapter } = botbuilder;

const expressApp = express(); …

Why on earth do I have to import the botbuilder before initializing express? Can someone please explain this to me.

1reaction
anusharrcommented, Jul 17, 2020

@geckgecko @janandreschweiger, thanks for the above info. I will update the thread soon with my findings.

Read more comments on GitHub >

github_iconTop Results From Across the Web

BotFrameworkAdapter.processActivity(): 401 ERROR ... - GitHub
js process with a non-zero exit code. BotFrameworkAdapter.processActivity(): 401 ERROR - Error: Unauthorized Access. Request is not authorized ( ...
Read more >
Error: BotFrameworkAdapter.processActivity(): 401 - Microsoft ...
I cannot connect my MS Teams messaging extension with the MS Teams App. On running the action I get the following error:
Read more >
Error: BotFrameworkAdapter.processActivity(): 401 ERROR
One of a sudden adapter.processActivity fails with these two error messages when sending a chat-message to the bot: 1. Error Message:
Read more >
OfficeDev/generator-teams - Gitter
BotFrameworkAdapter.processActivity(): 401 ERROR - Error: Unauthorized Access. Request is not authorized // Local hosted with ngrok.
Read more >
BotFrameworkAdapter.processActivity - Javascript - Tabnine
Listen for incoming activities and route them to your bot main dialog. server.post('/api/messages', (req, res) => { adapter.processActivity(req, res, async ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found