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

There was an error sending this message to your bot: HTTP status code InternalServerError

Open ghost opened this issue 9 years ago • 15 comments

Want to use one instance of bot for multiple bots handling.

I override BotAuthentication method OnActionExecutingAsync.

 public class FilterClass: BotAuthentication
    {


        public override async Task OnActionExecutingAsync(HttpActionContext actionContext, CancellationToken cancellationToken)
        {
            
             var pom = actionContext.ActionArguments;
            if (actionContext.Request.RequestUri.AbsoluteUri.ToString().Contains("bot2"))
            {
                MicrosoftAppId = "bot2 id";
                MicrosoftAppPassword = "pass";
                BotClass.BotID = "bot1";
            }
            else if (actionContext.Request.RequestUri.AbsoluteUri.ToString().Contains("bot1"))
            {
                MicrosoftAppId = "bot2 id";
                MicrosoftAppPassword = "pass";
                BotClass.BotID = "bot1";
            }
            else
            {
                MicrosoftAppId = "";
                MicrosoftAppPassword = "";
            }


        }

And edit my controller:


 [FilterClass]
    public class MessagesController : ApiController
    {

       
        public async Task<HttpResponseMessage> Post([FromBody]Activity activity)
        {
            if (activity.Type == ActivityTypes.Message)
            {
                try
                {
                    var stateClient = activity.GetStateClient();
                    BotData userData = await stateClient.BotState.GetUserDataAsync(activity.ChannelId, activity.From.Id);
                    userData.SetProperty("ApplicationAccountBotId", BotClass.BotID);
                    await stateClient.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData);

                    await Conversation.SendAsync(activity, () => new RootDialog());
                }

But its not working. It throws an error in botframework dashboard :

There was an error sending this message to your bot: HTTP status code InternalServerError

Any idea ?

ghost avatar Feb 23 '17 15:02 ghost

I'd run your bot's web service under the debugger, and look for thrown exceptions to help understand the 500 http status code:

https://docs.botframework.com/en-us/technical-faq/#look-for-exceptions

However, since you're using the builder dialog stack, you also need to fix the outgoing authentication calls as well to support "multiple bot in single process" scenarios - for example https://github.com/Microsoft/BotBuilder/issues/2258#issuecomment-280506334

willportnoy avatar Feb 24 '17 05:02 willportnoy

I used solution you posted. When i test it locally, this function :

public Task<bool> IsAuthenticationDisabledAsync()
        {
            return Task.FromResult(!this.Credentials.Any());
        }

Should return empty appid and password ? - But simulator throws an error : http://prntscr.com/ecqwly

Why ?

ghost avatar Feb 24 '17 09:02 ghost

Hi,

I have created Bots in BotFramework portal and have linked up with BotBuilderSDK and have enabled channels like DirectLine, WebChat. It was working fine till today morning we are getting messages as "Sorry, my bot code is having an issue"..It is not working. Any suggestions?..In the error list of DirectLine it is showing as "There was an error sending this message to your bot: HTTP status code InternalServerError"

rahulsarkar123 avatar Feb 24 '17 11:02 rahulsarkar123

@rahulsarkar123 open new thread and paste your code there.

ghost avatar Feb 24 '17 11:02 ghost

created a new thread and have pasted the code

rahulsarkar123 avatar Feb 24 '17 11:02 rahulsarkar123

@lonche are your app ID and password non-empty?

willportnoy avatar Feb 27 '17 00:02 willportnoy

They are empty when i use simulator. How to test it properly ?

ghost avatar Feb 28 '17 08:02 ghost

The LUIS account trial period got expired, it exceeded 10,000 calls / month, I generated new keys and configured bots.It worked.

Thanks & Regards

Rahul Sarkar

Unique Identity: Emerging Technologies

Accenture

Mobile : +91 7829306427

Email : [email protected]


From: activ8 [email protected] Sent: Tuesday, February 28, 2017 1:59:11 PM To: Microsoft/BotBuilder Cc: Sarkar, Rahul B.; Mention Subject: Re: [Microsoft/BotBuilder] There was an error sending this message to your bot: HTTP status code InternalServerError (#2332)

They are empty when i use simulator. How to test it properly ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_Microsoft_BotBuilder_issues_2332-23issuecomment-2D282974716&d=DwMCaQ&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=QslpQpuOneGqy6e8F7Jf9wWEOB9eLjGjUUt9mnOdl0k&m=RmJ9cNUdOJd9j_uo651zAgMxq6qtJ9HvRfrNl452e6k&s=njnGnFydeyF9d9ZIAK24ile6apDcEtG4tGmc_RwAY38&e=, or mute the threadhttps://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AYzHIdJYsrjGtKzZuGlXF962PWkAGHB9ks5rg9rXgaJpZM4MKHEJ&d=DwMCaQ&c=eIGjsITfXP_y-DLLX0uEHXJvU8nOHrUK8IrwNKOtkVU&r=QslpQpuOneGqy6e8F7Jf9wWEOB9eLjGjUUt9mnOdl0k&m=RmJ9cNUdOJd9j_uo651zAgMxq6qtJ9HvRfrNl452e6k&s=EVqcOkzbGVLSWoGdCp8SEvxwd86nGU75fL9lKL4tuM8&e=.


This message is for the designated recipient only and may contain privileged, proprietary, or otherwise confidential information. If you have received it in error, please notify the sender immediately and delete the original. Any other use of the e-mail by you is prohibited. Where allowed by local law, electronic communications with Accenture and its affiliates, including e-mail and instant messaging (including content), may be scanned by our systems for the purposes of information security and assessment of internal compliance with Accenture policy.


www.accenture.com

rahulsarkar123 avatar Feb 28 '17 08:02 rahulsarkar123

@lonche I don't know that the emulator deals well with multiple bot authentication credentials pointing to the same endpoint. @eanders-MS for visibility.

willportnoy avatar Mar 02 '17 22:03 willportnoy

@lonche @eanders-MS confirmed in https://github.com/Microsoft/BotBuilder/issues/2352#issuecomment-283803938 that the emulator does not currently support multiple credentials per endpoint.

willportnoy avatar Mar 14 '17 16:03 willportnoy

So, how to debug this ? Any idea ?

ghost avatar Mar 17 '17 09:03 ghost

Since you can't use the emulator to emulate multiple credentials per endpoint, you can attach your debugger to an instance running in the cloud.

willportnoy avatar Mar 20 '17 15:03 willportnoy

Yes. But how to debug that ? Did you try something similar ?

ghost avatar Mar 20 '17 22:03 ghost

@willportnoy for something as simple as context.PostAsync("some message"). Should I be wrapping this code with try/catch to react to a thrown exception? I'm asking because I cannot replicate the 500 errors easily. My bot works fine with the emulator, but once it is deployed in our on prem machines I get these errors inconsistently on the sms channel. I'm thinking I need to catch and log these exceptions somewhere in order to diagnose or resend the message.

arthurtina724 avatar May 03 '17 21:05 arthurtina724

@arthurtina724 that's up to you. if you don't wrap those calls, they will propagate up the dialog stack.

willportnoy avatar May 12 '17 23:05 willportnoy