telegraf: Hi! Cant run simple webhook bot from your example ((((((
Context
On webserver:
- Telegraf.js Version: “telegraf”: “^3.24.0”
- Node.js Version: v9/2/0
- Operating System: Ubuntu 18
And winows local machine fails too:
- Telegraf.js Version: “telegraf”: “^3.24.0”
- Node.js Version: v9/2/0
- Operating System: Win 10 Pro x64
Expected Behavior
Bot listens and answers. I have Centos
Current Behavior
Bot not answers. Not listen (
Steps to Reproduce
This is my code:
const Telegraf = require('telegraf')
const bot = new Telegraf(process.env.BOT_TOKEN || 'xxxxxxx')
bot.command('image', (ctx) => ctx.replyWithPhoto({ url: 'https://picsum.photos/200/300/?random' }))
bot.on('text', ({ replyWithHTML }) => {console.log('Incoming');return replyWithHTML('<b>Hello</b>')})
// Set telegram webhook
// npm install -g localtunnel && lt --port 6000
bot.telegram.setWebhook('https://-----.localtunnel.me/secret-path')
// Start https webhook
bot.startWebhook('/secret-path', null, 6000)
On windows i see next text:
(node:11672) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): FetchError: request to https://api.telegram.org/botxxxxxxxx/setWebhook failed, reason: certificate has expired
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 31 (11 by maintainers)
https://github.com/telegraf/telegraf/issues/524#issuecomment-427011881
When you are trying to use localtunnel, you need to run
lt --port 3000first Then it generate you your private link, which you should use instead of"https://-----.localtunnel.me"This will proxy all queries and apply them at 127.0.0.1:3000@eugen35, Nope If you are using Localtunnel, you don’t need to install tls and send cert to the telegram. Because it should provide own valid certificate
But if you run your own web server on white IP address, you can run https server (express, nginx, … or inside
startWebhook) with your TLS options without using Localtunnel proxy If you don’t have white IP, try to use Polling mode or forward portSecond thing/ When you send selfsinged certificate, you should send content of file, not that file name Mb that thing raise cert expired error, but it is invalid certificate also
It should be looks like
If you are using port forwarding
Notes
NEW! If you’re having any trouble setting up webhooks, please check out this amazing guide to Webhooks .
Its working ))))