Ngrok returns 405 error while tunneling my localhost - botframework

I have a web app bot that I would like to remote it so a few people can test it. I am using Bot Framework Emulator to test it locally and it works wonders, but I'm thoroughly failing to make ngrok host it.
(I actually managed doing it using the ...azurewebsites.net/api/messages link my app has in Azure with another bot, but I couldn't with this one, so I'm trying with the link ngrok offers me - both bots, the one I managed and this one, are hosted in Azure, but I don't know how to make it available to remote access)
Steps I'm taking:
Deploy the app in Visual Studio so it runs on localhost:3979;
Open port externally in ngrok using ngrok
3979 http -host-header=rewrite localhost:3979;
Get one of the forwarding URLs ngrok provides me, like
https://3d609207.ngrok.io
Insert previous URL in Bot Framework Emulator;
Click Connect.
Both in ngrok and in Bot Framework Emulator returns me 405 Method Not Allowed.
I tried accessing the link I inserted in Bot Framework Emulator and I normally have the page I would see while hosting my bot locally:
Describe your bot here and your terms of use etc.
Visit Bot Framework to register your bot. When you register it,
remember to set your bot's endpoint to
https://your_bots_hostname/api/messages
But I can't send nor receive messages in Bot Framework Emulator.
Additionally, ngrok prints this under the HTTP request headline:
HTTP Requests
-------------
POST / 405 Method Not Allowed
GET /favicon.ico 200 OK
GET / 200 OK
My MSAppID and Password are configured properly in web.config, and compilation results in no error, so I doubt it's something on the code (unless there is some configuration in the code that prevents this bot being accessed remotely for a reason, but I have no idea).
I would very much appreciate any help on this issue. Thanks for your time.

Both in ngrok and in Bot Framework Emulator returns me 405 Method Not Allowed
I can reproduce the issue on my side if I just provide https://xxxxxxxx.ngrok.io as message endpoint.
Please try to specify https://xxxxxxxx.ngrok.io/api/messages as message endpoint, which works for me.

Related

What is the request that whatsapp cloud api does to verify a webhook?

I'm able to verify the webhook using glitch from the getting started:
https://glitch.com/edit/?fbclid=IwAR2YTjZuGGM9Hi6T_v1eZh_nV6_HY3RYn_8lll4gY1REa_bJy6ZAuq6tkKQ#!/whatsapp-cloud-api-echo-bot
my local server (in a subdomain with https enabled) has the same behavior as glitch and show "WEBHOOK_VERIFIED" on the log for the request:
/webhook?hub.mode=subscribe&hub.verify_token=xpto123&hub.challenge=123
but when try to verify my local server the request from meta does not reach the server.
chrome showing that the connection to the server is secured
After more tests I found that my local server was been blocked by the ISP, understood it after test with another connection.
I made my own server and had tried ngrok and other programs to run it from local host with https redirect but whatsapp doesn't allow the use of those programs.
In the end, my error was that the URL HAS to end in /webhook or else, it won't even send the request. Then it'll send a GET request and you have to return the hub.challenge query param after making sure that the provided token from them is the one you set up. This is my code using NodeJS
if(req.query['hub.verify_token'] === process.env.VERIFY_TOKEN) return res.status(200).send(req.query['hub.challenge'])

ngrok 404 error with

I'm working on ASP.NET Core application. I had to host online for testing few cases. I tried using ngrok. Everything perfectly done as show on:
C# Corner link
I could see the request being logged in ngrok
But browser stops with 502 bad Gateway.

Trying to get direct line to point ngrok failing

I have run my bot locally (success)
I have set ngrok (success)
I have tested the remote url (success)
I have added Direct Line webchat to my local running site (success)
I have set up Direct Line and used this secret in my webchat (success)
However, I still get the old bot response (hosted on Azure)
So I have gone to the bot framework website --> my bot --> settings --> Messaging endpoint and set the URL as my ngrok address
It seems to be saved, but I get a strange popup saying
CorrelationID : SHUjnuhs=
Or some other random shortcode.
Seems to be an error from API/botmanager and response to an error 500
Just wondered if there is something else I am missing here in order to get direct line speaking to my locally running bot
Usually, that error means that the messaging endpoint has a space at the beginning and so it's not being saved (that's why you are seeing the old message). Reload the page, and before saving make sure there is no space at the begiining of the url.

ASP.NET Unauthorized in Postman using IIS Express, but works in Chrome

I am trying to test an ASP.NET Web Api locally using IIS Express. When I use Chrome and hit the url (localhost:5000/api/test, for example) the json displays fine, but when using Postman I keep getting unauthorized 401.2 when hitting the same url. The api controller has Anonymous access on the route.
On the error message, one of the likely causes is:
Integrated authentication is enabled and the request was sent through a proxy that changed the authentication headers before they reach the Web server.
Is Postman somehow changing the headers?
[2019 Update]
Got the same issue, I couldn't debug an ASP Core 2.1 API using Postman when running on the local machine using IIS Express. I kept on having "Could not get any response" despite it was working fine on a browser.
Following troubleshooting steps explained here PostmanLabs Github, I noticed into Postman console that this was coming from a certificate issue.
Disabling SSL Verification from Postman Settings > General allowed the request to pass through.
Looks like it's your proxy.
I haven't found the proxy setting in postman. So I deleted postman for Win and installed postman for Chrome. Possibly Postman gets the environment from Chrome.
Anyway the resolution is to use Postman for Chrome instead of Postman for Win.
I have a localhost WebAPI site up with IIS Express (HTTPS). Postman started to respond as expected to GETs and POSTs after I changed (in Postman)
File --> Settings --> Proxy
to: "Use the system proxy"
and turning on: "Respect HTTP_PROXY ...".
I had earlier set up a custom proxy that wasn't working with HTTPS.

How do I capture https requests with Postman native app using Windows 10?

I am using the Postman native app on Windows 10 and am struggling with trying to capture https requests. Postman's Documentation for this is for Mac and not Windows.
In particular, I am working on a web application that creates a session cookie upon login that needs to be included in most requests in order to be authorized. When I was using the Chrome App, Postman Interceptor achieved this (see https://stackoverflow.com/a/32436131/3816779).
Here's what I've tried so far:
Turn on the Proxy in Postman with port 5555.
Configured windows to send http and https requests through Postman's proxy server (127.0.0.1:5555).
This allows http requests to be captured in Postman
But when trying to connect to https sites, I get an error
Here are my Postman settings if that helps.
Update I ended up switching back to the Chrome App, which uses the "Interceptor" instead of a "Proxy Server" to capture traffic.
Unfortunately, capture https requests with postman native app is impossible in some case according to the official doc: Capturing HTTP requests
Note: for the Postman native apps, request captures over HTTPS will not work if the website has HSTS enabled. Most websites have this check in place.
Postman's proxy now supports HTTPS traffic - https://blog.postman.com/postmans-proxy-now-fully-supports-https-endpoints/
Once you install a CA certificate that Postman generates for your installation, capturing HTTPS requests should be seamless.
Disclaimer: I work at Postman
With Google Chrome i don't know how to fix the issue. But you can use to open the web page for example IE..
EDIT:
Or MAYBE you can start Google Chrome with parameter --ignore-certificate-errors to ignore the error message.
Postman Interceptor is available for Postman native apps which supports both features:
1. Capturing requests
2. Syncing cookies
Learn more here.
Just check HTTPS in setting and will work for you

Resources