microsoft / BotFramework-Emulator

A desktop application that allows users to locally test and debug chat bots built with the Bot Framework SDK.
https://aka.ms/botemulator
MIT License
1.79k stars 749 forks source link

Setting up channel debug locally through emulator does not work #1271

Open mydiemho opened 5 years ago

mydiemho commented 5 years ago

Github issues should be used for bugs and feature requests. Use Stack Overflow for general "how-to" questions.

Version

What version of the Emulator are you using. V4

Describe the bug

Setting up channel debug locally through emulator does not work

To Reproduce

Steps to reproduce the behavior:

  1. Hook into local bot through emulator.
  2. Update bot endpoint on Azure portal to use ngrok.
  3. Website get 502 when attempting to talk to the endpoint.

Expected behavior

It just works.

Screenshots

If applicable, add screenshots to help explain your problem.

Additional context

It works fine when I start ngrok manually following this instruction

[bug]

drub0y commented 5 years ago

I worked with My on this and experienced the same thing for myself.

Specifically, if you look at the ngrok traces, the external traffic coming in from the Bot Framework Service is ending up getting 404 statuses finding /api/messages. The endpoint is definitely there though because we can hit it through localhost no problem. Additionally, we can uncheck the "Bypass ngrok for local addresses" option and watch the emulator send requests through ngrok successfully where as an external channel such as Web Chat still fails with the aforementioned 404.

~My guess is that the emulator is not actually configuring the Host header when it runs ngrok and this results in the request not being able to be handled by the local server software because the Bot Framework Service will use the ngrok hostname.~

UPDATE: I just thought to check the Host header coming from each via the ngrok traces and they are always the ngrok Host in both the WebChat case and emulator as a client (with bypass off) case.

Emulator sending a message through ngrok image

Portal Test WebChat sending a message through ngrok image

In the above screenshots we can see that emulator is sending calls to the directline endpoint and that seems to be what is exposed by the ngrok endpoint vs the Test WebChat channel sending through the Bot Framework Service and just trying to deliver the activity to the bot's endpoint at /api/messages.

So... obviously what's exposed over ngrok is not the bot endpoint, but rather the emulator's DirectLine endpoint??? Is this expected???

drub0y commented 5 years ago

For anyone coming into this issue right now, the answer is don't use the emulator and run ngrok manually from the command line like so:

> ngrok http 1234 -host-header="localhost:1234"

Where you replace the 1234s with your bot's local server port (e.g. 3978).