Search code examples
asp.net-coretelegramvpntelegram-botngrok

Debug bot on local machine via ngrok and vpn


I want to debug a simple bot for telegram on my local machine.

I use Telegram.Bot and web hooks on asp.net core 3.0. I am from Russia and Telegram is blocked in my country, so I need to use a VPN if I want to connect to the Telegram API via Telegram.Bot.

I started ngrok but ran into a problem. Telegram post requests do not arrive on my local machine. But the get requests that I do myself on ngrok come correctly.

I run ngrok with the command: ngrok http 54823 -host-header="localhost:54823". 54823 - my default debug port in vs, not ssl.

I get an url: https://5bf38bda.ngrok.io

Then I make requests: get: https://5bf38bda.ngrok.io/api/message/update and it activates breakpoint. Then I make a post from the Telegram client and nothing happens.

In ngrok web interface i see next picture: get request post request

X-Forwarded-For field is different for get(uses ip vpn) and post(uses unknown ip) requests. Could this be the problem? Can I use ngrok with vpn this way? Or will it only work without vpn? Need help, thanks a lot!


Solution

  • Answer is here: telegram currently supports the following ports: 443, 80, 88 and 8443

    I changed the port in launchSettings.jso to 443 and this solved the problem.