There was an error sending this message to your bot 502 Bad Gateway

Matthew Reeds 0 Reputation points
2023-04-12T14:17:57.63+00:00

My scenario is I have a bot created using Bot Framework SDK 4.18.1 with .Net Core. This bot pulls data from on-premises databases that are not provisioned in the cloud. Due to this, I need my bot to be hosted on one of our locally managed servers.

If I Start the code locally I can test just fine in bot emulator using the localhost endpoint and all functionality works just fine. Because local testing is successful I've used Visual Studio Publish feature to publish the project to a local folder of mine so I can add it to my IIS server to host the application. For context, I am able to browse the Https site and the "Your bot is ready!" screen pulls up.

I wasn't able to connect to the endpoint now from emulator due to the ngrok requirement but that's not the issue. I needed a way to communicate with my bot. So after reading plenty of MS docs and SO pages, I then published the bot to my Azure portal using Visual Studio Publish feature once again. So now I have an Azure bot and an Azure app service. and I configured the AppId and AppPassword configurations for the service to match the bot. I created a .Net WebApp and embedded the WebChat iframe from my Azure bot. This iframe works properly when the bots messaging endpoint is set to the cloud URI. I read that I could change that messaging endpoint to be my locally managed versions endpoint, so I made that change but here's where the problems begin. Now when I attempt to "Test in WebChat" there's a blank screen. As well as in my front-end app there's seemingly no attempt at connecting as there's usually the spinning "connecting" wheel. My bot is designed to greet at the beginning of a conversation. As well as no errors in the console until I manually send the first message. Once I send a message I get a console error that reads: "POST https://webchat.botframework.com/v3/directline/conversations/{conversationId}/activities 502 (Bad Gateway)"
I've even added my front-end site to be hosted on the same server as my bot hoping that would resolve the issue, but no luck. For additional context, I am able to reach my bot site from outside the hosting machine and can view the "Your bot is ready!" screen. As well as accessing my WebApp site from outside as well. So I know the URL's are both accessible. Not sure if this comes down to a configuration issue, or a firewall issue sending requests back and forth. Any help or insight would be appreciated! Thanks

Azure AI Bot Service
Azure AI Bot Service
An Azure service that provides an integrated environment for bot development.
747 questions
{count} votes