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

Getting Error: "There was an error sending message to your bot. HTTP status code Unauthorised"

Open ashwani-ksprof opened this issue 8 years ago • 27 comments

Bot Info

  • SDK Platform: .NET
  • SDK Version: Bot Builder SDK 3.9.0.0
  • Active Channels: Directline and WebChat
  • Deployment Environment: In-house Server

AppID = aa0cd191-5aea-4c4a-8fad-73f046e65fe6 BotHandle = BrianStaging

Issue Description

I am getting below error all of a sudden on a running bot.

image

I have deployed the Bot solution on to our in house server with valid SSL certificate. Then endpoint of the API is https://brian.birlasoft.com/uat/api/messages

The same app was working till 28 Feb 2018 and now it is giving the above error when using Dirctline and WebChat channels.

But, when we try to connect through Emulator then it works seems like emulator directly connect to Bot API bypassing the channel connector.

Please help me troubleshooting the issue as we are stuck here.

Here is the Directline secret key we are using to connect to the bot. [mod: RemovedSecret]

ashwani-ksprof avatar Mar 07 '18 11:03 ashwani-ksprof

Same thing happened with multiple of my bots , try re-generating your app ID and password and use the new one instead of the old , it will solve the problem.

Aashish-Amber avatar Mar 07 '18 11:03 Aashish-Amber

On the bot side this error shows up: ChatConnector: receive - invalid signing key or OpenId metadata document. SDK Platform : NodeJS, Botbuilder version : 3.14.0

preetham avatar Mar 07 '18 11:03 preetham

Thanks for the suggestions. However, I have already created a new app with new set of AppId and Password, even then it is not working. As I mentioned in the issue description that I have been able to connect to my Bot using emulator which require to pass AppId and Password. So AppId and Password is working but seems like the issue with Directline and webchat channel.

Any thoughts around this.

ashwani-ksprof avatar Mar 07 '18 12:03 ashwani-ksprof

The same problem with ChatConnector: receive - invalid signing key or OpenId metadata document. on our multiple bot instances. It fails randomly, not on every request. Error appears for requestst sent at least through directline, webchat and facebook channels. Restart of bot solves problem for a while.

dvorakjan avatar Mar 07 '18 12:03 dvorakjan

+1 - facing the same issue since yesterday night. Heres the error we're getting on the bot side

ERROR: ChatConnector: receive - invalid signing key or OpenId metadata document. Our MSA ID - 71fad264-9fd6-4ecd-808d-becdbc3b7eb1

Our SSL certs seem to be fine.

our botbuilder version is 3.11 .

Kannaj avatar Mar 07 '18 12:03 Kannaj

@ashwani-ksprof The issue occurs for facebook channel too, I don't think it's limited to webchat/directline.

preetham avatar Mar 07 '18 13:03 preetham

Please try restarting your bot service and see if that fixes the issue.

JasonSowers avatar Mar 07 '18 18:03 JasonSowers

Restart of bot service fixed issue (now its more than 7 hour since restart) for all our bots. But we are afraid that it can come back again since we don’t know the reason. Should we use some other/faster channel than Github in case of future problems?

dvorakjan avatar Mar 07 '18 20:03 dvorakjan

Encountered the same issue on my production bot for my enterprise client. May I know what's the official solution to this issue? I need to answer to my client regarding this.

Will suggest restarting bot service to my client for now.

DarkInsight85 avatar Mar 08 '18 02:03 DarkInsight85

Hi @DarkInsight85

The official solution is to restart the bot:

image

EricDahlvang avatar Mar 08 '18 04:03 EricDahlvang

Ok. When you say restart the bot, do you mean to say restart the server where I have published my bot code. I have published it on the in-house Windows 2008 R2 server with IIS 7.5 and I have already restarted IIS server several times. If you are suggesting to restart the bot which I have created using Bot Channel Registration Service on Azure, then please guide me how can I restart that as I am not able to locate form where I can do that,

Thanks

ashwani-ksprof avatar Mar 08 '18 06:03 ashwani-ksprof

@ashwani-ksprof please try upgrading the bot builder sdk.

EricDahlvang avatar Mar 08 '18 07:03 EricDahlvang

@EricDahlvang I have upgraded my bot with SDK version 3.13.1. But I am still getting the same issue. Please guide me how to resolve this as we had to make this bot live for some pilot user for testing and has already been delayed by one week.

ashwani-ksprof avatar Mar 08 '18 11:03 ashwani-ksprof

@ashwani-ksprof

Your issue appears to be different from the others in this thread. Have you tried setting up ngrok, and changing the messaging endpoint, and debugging locally? https://blog.botframework.com/2017/10/19/debug-channel-locally-using-ngrok/

If you can share your project with me, please email it to the address on my GitHub profile: https://github.com/EricDahlvang

EricDahlvang avatar Mar 08 '18 21:03 EricDahlvang

@EricDahlvang Yes, I did tried with ngrok and debugged the code locally for directline and web chat channel. It is working perfectly.

I am not sure on sharing the code as it would be a compliant issue as suggested by seniors in my team. Let me check again if I could share the code, meanwhile, if you can suggest or have any other idea to fix the issue, please let me know.

ashwani-ksprof avatar Mar 09 '18 08:03 ashwani-ksprof

I notice you mentioned that the messaging endpoint is: https://brian.birlasoft.com/uat/api/messages ... but that is not actually the messaging endpoint. I would double check the Messaging Endpoint, as well as the MicrosoftAppId and MicrosoftAppPassword.

How are you using the DirectLine? Do you have your own client? are you using the WebChat iframe?

EricDahlvang avatar Mar 12 '18 16:03 EricDahlvang

What else, then, should be the messaging endpoint? This is what we configure in the bot app on Azure.

image

We have been running this bot for the last 9 months and it was working just fine. We have developed our own client which is a mobile app (android) using DirectLine channel. We are using DirectLine secret key for communicating with the bot. Yes, we are also using WebChat channel to just plugin the bot in out intranet web site, but not using WebChat iframe, instead, we are using botchat.js to initiate the conversation with the bot like below:

<script> var email = '[email protected]'; var userName = 'ashwani'; var model = { "userId": email, "userName": userName, "botIconUrl": "~/images/user.jpg", "secret": "*********-PQc.********.Ber3I6Bu_*****************************", "iconUrl": "~/images/user.jpg", "directLineUrl": "https://webchat.botframework.com/v3/directline", "webSocketEnabled": "false" }; </script> <script> BotChat.App({ directLine: { secret: model.secret, token: model.token, domain: model.directLineUrl, webSocket: false }, user: { id: model.userId, name: model.userName }, bot: { id: model.botId, name: model.botName }, resize: 'window' }, document.getElementById("BotChatElement")); </script>

Any other information I can help you with, please let me know.

ashwani-ksprof avatar Mar 13 '18 06:03 ashwani-ksprof

@ashwani-ksprof

It is not clear to me why your bot is experiencing this issue. When you say you've setup ngrok, and debugged locally, did you do this by changing the messaging endpoint in Azure to point to the ngrok endpoint? Then use webchat, or your custom directline client, to connect to the bot? (i'm not referring to using the emulator)

You could also try regenerating your secrets. (Though I've never seen this solve anyone's issue before, I've also never seen this unexplained authorization exception.)

Lastly, why are you using 'https://webchat.botframework.com/v3/directline' for the directLineUrl above? I think it should be https://directline.botframework.com/v3/directline reference: https://github.com/Microsoft/BotFramework-DirectLineJS/blob/af5afc7e9dd4cb7ef5f50ae3ee9881f939556467/src/directLine.ts#L287

EricDahlvang avatar Mar 13 '18 07:03 EricDahlvang

@EricDahlvang

Thanks for the response. Yes, I used the same endpoints which ngrok generates to debug the code locally and I tested with both channel WebChat and DirecLine.

I'll try regenerating the secret key again. Though I also feel it will not resolve the issue as I have created a new Bot App (Bot Channel Registration) on Azure and configured the DirectLine channel for fresh secrets.

For the DirectLineUrl, we have been using this "https://directline.botframework.com/v3/directline" endpoint only. I was just trying to see if this 'https://webchat.botframework.com/v3/directline' endpoint will work or not and surprisingly this was also working.

What next now? Can we setup something where I can share my screens to give you more clear picture?

ashwani-ksprof avatar Mar 13 '18 10:03 ashwani-ksprof

@ashwani-ksprof Yes, we can setup a time to do a skype screenshare. Please email me at the address on my profile: https://github.com/EricDahlvang

If you could create a sample project that demonstrates this issue, it would be helpful. I don't need your secrets or passwords, but just a small project that I can use to recreate the issue.

EricDahlvang avatar Mar 13 '18 18:03 EricDahlvang