question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi! Cant run simple webhook bot from your example ((((((

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:31 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
tva10commented, Oct 4, 2018

https://github.com/telegraf/telegraf/issues/524#issuecomment-427011881

{ method: ‘setWebhook’, payload: { url: ‘https://-----.localtunnel.me/secret-path’ } } }

When you are trying to use localtunnel, you need to run lt --port 3000 first 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

2reactions
tva10commented, Oct 3, 2018

@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 port

Second 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

bot.telegram.setWebhook('https://190.1.50.51:8443/secret-path',{ source: fs.readFileSync(  './pathTo/cert.pem') })
  .catch(err=>console.log(err))

bot.startWebhook('/secret-path', tlsOptions, 8443, '190.1.50.51')

If you are using port forwarding

// also need to add rule 190.1.50.51:8443 -> 192.168.0.10: 3000
bot.telegram.setWebhook('https://190.1.50.51:8443/secret-path',{ source: fs.readFileSync(  './pathTo/cert.pem') })
  .catch(err=>console.log(err))

bot.startWebhook('/secret-path', tlsOptions, 3000, '192.168.0.10')

Notes

  1. You will not be able to receive updates using getUpdates for as long as an outgoing webhook is set up.
  2. To use a self-signed certificate, you need to upload your public key certificate using certificate parameter. Please upload as InputFile, sending a String will not work.
  3. Ports currently supported for Webhooks : 443, 80, 88, 8443 .

NEW! If you’re having any trouble setting up webhooks, please check out this amazing guide to Webhooks .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Intro to Webhooks - Real Time App Automation (Discord Bot ...
Your browser can't play this video. Learn more. Switch camera ... Intro to Webhooks - Real Time App Automation (Discord Bot, Slack, GitHub)....
Read more >
Sending messages using Incoming Webhooks - Slack API
Incoming Webhooks are a simple way to post messages from apps into Slack. Creating an Incoming Webhook gives you a unique URL to...
Read more >
How to Get Started with Webhooks by Zapier
Create your Zap and configure your webhook URL but don't enable your Zap quite yet! · Go into the triggering app and do...
Read more >
Got problems with webhook to Telegram Bot API
It means, that your bot can't react to your text messages, and you will not receive any webhooks! You can note, that "allowed_updates"...
Read more >
Setting your Telegram Bot WebHook the easy way
That being said, the quickest and easiest way to set a WebHook for your Bot is to issue a GET request to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found