Skip to content

Webhook does not even touch server #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
bilalbayasut opened this issue Jan 6, 2016 · 48 comments
Closed

Webhook does not even touch server #72

bilalbayasut opened this issue Jan 6, 2016 · 48 comments

Comments

@bilalbayasut
Copy link

I've been installing webhook, but it does not work. I have a self-signed-certificate that i've generated from my private key using :

openssl req -newkey rsa:2048 -sha256 -nodes -keyout YOURPRIVATE.key -x509 -days 365 -out YOURPUBLIC.pem -subj "/C=US/ST=New York/L=Brooklyn/O=Example Brooklyn Company/CN=YOURDOMAIN.EXAMPLE"

I've been trying all kind of certificate formats and still the bot does not reply.. any idea?

@MBoretto
Copy link
Collaborator

MBoretto commented Jan 6, 2016

Set log as explained in the doc, and see if you receive the update, could be a curl problem of the bot due to the php version. Did you try to receive update with the command line? it works?

@bilalbayasut
Copy link
Author

yes, I did.. and it works if only accessing getupdates method

@bilalbayasut
Copy link
Author

I have 3 kind of files from the ssl provider, CACertificate-1 , 2, and ServerCertificate, but all of them in cer format.. but I see the doc of webhook, it requires .pem format.. which file should I upload actualy? :(

@ericxxp
Copy link

ericxxp commented Jan 6, 2016

it works fine for me, no problems at all

@MBoretto
Copy link
Collaborator

MBoretto commented Jan 6, 2016

@ericxxp did you use certificates? Can you describe the procedures to @abutuffah ?
Thanks

@alpastar
Copy link

alpastar commented Jan 7, 2016

the cert must be one which is currently used by your web server (https)
did you make it enabled with your web-server ?

@bilalbayasut
Copy link
Author

yes, but what is the format? is it pem files? crt, cer or any other? yes, I've checked to the ssl issuer, and everything is valid

@alpastar
Copy link

alpastar commented Jan 7, 2016

my system is ubuntu 14.4 LTS (upgraded from 12.4 LTS , but same certificate )

'/etc/ssl/certs/ssl-cert-snakeoil.pem' public-key (upload to telegram)
'/etc/ssl/private/ssl-cert-snakeoil.key' private-key

@ericxxp
Copy link

ericxxp commented Jan 8, 2016

HI Abutuffah,
the ssl should be fully chained and you must combine all the files provided by the ssl issuer into one file .crt format

@alpastar
Copy link

i've got a same error with abutuffah (self signed certificate)
got a Webhook was set message from telegram but no hook occured

telegram send no error message though there is error in php
i have fixed permission error in my server
i have fixed CN in my certificate as my domain

https page test -> ok
calling https://mydomain/ hook.php -> ok, input empty error occur, file_put_contents occur
calling https://mydomain/getUpdatesCLI.php -> error, another webhook is set
in local environment , it seems ok
but though i sent message in telegram , there is no hook occured.

@MBoretto
Copy link
Collaborator

No logs at all like @abutuffah ?

@alpastar
Copy link

yes, absolutely no log
i inserted file_put_contents() at first line in hook.php , and even this line not worked

@MBoretto
Copy link
Collaborator

@alpastar @abutuffah could you provide your php and curl version?
Do you have the possibility to read php log file? Maybe an error occurred when webhook was setted.
Is there any way to understand if the certificate has been correctly stored?

@alpastar
Copy link

PHP 5.5.9-1 ubuntu4.14 (by php -v)
curl 7.35.0 ( by curl --version)

Maybe an error occurred when webhook was setted.
i dont think so. there is no error log (AFAIK)
i got the [Webhook was set] message from telegram
and when trying to getupdates , i got this message
{"ok":false,"error_code":409,"description":"[Error]: Conflict: another webhook is active"}

i think this means setting webhook is ok.
.
i'd like to know whether there is anybody who succeeded with self-signed-certicate
through this library.

@Albertogon
Copy link

i have the same problem with self signed, all ok but no reply and not call from telegram

@hakdig
Copy link

hakdig commented Jan 17, 2016

I have never find a solution to use a self certificat.

I use lets encrypt, it's simple and works fine
.

@Albertogon
Copy link

without certificates i have the same problem
$result = $telegram->setWebHook($link);
or
$telegram->setWebHook($link, "./YOURPEM.cer");

@MBoretto
Copy link
Collaborator

@hakdig can you describe in detail what is and how to use?
@Albertogon what's the result of set webhook? I use it without self certificate.

@hakdig
Copy link

hakdig commented Jan 18, 2016

@MBoretto Let’s Encrypt is a new Certificate Authority (SSL, TLS) : It’s free, automated, and open.

It's very simple to use it, you have many tutorial on the web, example : https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-14-04

Github : https://github.com/letsencrypt/letsencrypt
Website : https://letsencrypt.org/

@alpastar
Copy link

still don't working with letsencrypt ,
upload cert.pem , setwebhook ok , but not working
upload fullchain.pem , setwebhook ok , but not working

what file did you upload?
/etc/letsencrypt/live/{mydomain}/cert.pem
/etc/letsencrypt/live/{mydomain}/chain.pem
/etc/letsencrypt/live/{mydomain}/fullchain.pem

(reference)
http://www.cubewebsites.com/blog/guides/fix-telegram-webhooks-not-working/

@MBoretto
Copy link
Collaborator

Did someone try to set the certificate and the webhook with another library? Let me know..

@Albertogon
Copy link

Powered by letsencrypt!!
Windows Server 2012 rc2
For windows with https://github.com/Lone-Coder/letsencrypt-win-simple#usage

@hakdig
Copy link

hakdig commented Jan 24, 2016

@alpastar If you use letsencrypt you have nothing to upload because it's not a SELF CERTIFICATE but a signed cert.

You have to generate your letsencrypt cert for your domain, config your Apache or Nginx server with previous generate cert (many tutorial on google) and after that just set your BOT URL in your webhook (so without cert file).

@alpastar
Copy link

@hakdig bingo !!!!, you saved my day

success with letsencrypt
the point is, just send my-url, with no certicate (no upload)

thanks.....

@hakdig
Copy link

hakdig commented Jan 25, 2016

@alpastar Nice to hear that, you're welcome.

@akokarev
Copy link

I have the same problem. I resolve it with https://www.ssllabs.com/ssltest/analyze.html. When I get Overall Rating = A-, bot is start work! The problem was with incorrect config in ssl.conf. I change it to:

SSLProtocol TLSv1.2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA:!RC4
SSLCertificateFile /etc/letsencrypt/live/mydomain.tk/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.tk/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/mydomain.tk/chain.pem
SSLCACertificateFile /etc/letsencrypt/live/mydomain.tk/fullchain.pem

@MBoretto
Copy link
Collaborator

MBoretto commented Mar 7, 2016

Hello!
I set the self signed certificate with the setWebhook() method.
I've wrote here some useful tips that should help during the installation!
Feel free to improve the wiki page!

@MBoretto MBoretto closed this as completed Mar 7, 2016
@aliemam
Copy link

aliemam commented Apr 17, 2016

Hi
I've been testing blog you wrote on this issue @MBoretto but it does not work. things i did:
use this command to create .pem and .key with CN="subdomain":
openssl req -newkey rsa:2048 -sha256 -nodes -keyout YOURPRIVATE.key -x509 -days 365 -out YOURPUBLIC.pem -subj "/C=US/ST=New York/L=Brooklyn/O=Example Brooklyn Company/CN=YOURDOMAIN.EXAMPLE"
then use this for .csr:
openssl req -new -key server.key -out server.csr
and:
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
in apache ssl config file (important lines):
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl .crl
SSLCipherSuite HIGH:MEDIUM:!MD5:!RC4
SSLProxyCipherSuite HIGH:MEDIUM:!MD5:!RC4

DocumentRoot "/var/www/html"
ServerName subdomain
ErrorLog "/usr/local/apache/logs/error_log"
TransferLog "/usr/local/apache/logs/access_log"
SSLEngine on
SSLCertificateFile "/usr/local/apache/conf/ssl/server.crt"
SSLCertificateKeyFile "/usr/local/apache/conf/ssl/server.key"

with this config browser resolved https://subdomain and i think its working and there is no problem here(i hope).
finally i uploaded .pem file to telegram and it was file the OK param was 200 and ... but it does not work. in access_log file when the hook was set and i communicate with bot nothing was recieved. there is no log no error nothing. i know letsencrypt might work. i wonder if this issue could be solved with self signed.

@MBoretto MBoretto reopened this Apr 18, 2016
@devsoft91
Copy link

@akokarev i reached rating A- too using letsencrypt and your same configuration (edited /etc/apache2/sites-enabled/default-ssl.conf) but still not reacting using webhook...

@danog
Copy link

danog commented May 14, 2016

I've got a similar issue: I'm getting a Webhook is already deleted message using caddy + hhvm + php5-curl while trying to set the webhook using php (everything works fine if I try to make the setwebhook request in my browser) : after including a few var_dumps I saw that the url parameter gets passed to curl but then isn't sent (the above mentioned message pops up if you try to set an empty webhook).
Anyone has any idea on why this is happening?

@danog
Copy link

danog commented May 14, 2016

Fixed by removing the CURL_SAFE_UPLOAD from the options array.

@MBoretto
Copy link
Collaborator

Thanks for sharing!

@daren-shan
Copy link

daren-shan commented Jul 29, 2016

Hi, did someone solve the problem?

i have this problem too,
i installed cert in a free host and upload cert to the telegram with curl but it doesn't work, also i checked server log but nothing received from telegram,
and there is something weird, this bot @BobRossBot which uses self signed cert was functional 2 day ago but not working today!

i followd these steps:
1- i got ssl cert private key and csr form my host,
2- i signed it with openssl commands
3- upload crt file to my host
4- upload crt file to telegram using curl (also i checked uploading pem ,etc)
5- i checked ssl whith one of ssl checking site and it was ok,
6- my site is not reachable because of self-signed ssl and browser ask to proceed or not.

@noplanman
Copy link
Member

was functional 2 day ago but not working today!

If that's your bot, reset the Webhook (Unset it, then Set it again). Due to an issue at Telegram, all Webhooks have been lost.

Did you follow the procedure for self-signed certificates step-by-step as explained in the readme file?

@daren-shan
Copy link

no, its not my bot, no again actually i set webhook manually from command prompt!

@noplanman
Copy link
Member

Ok, I have found the problem.

This issue is fixed in the develop branch. It has to do with the way the certificate is sent to Telegram. When we switched to Guzzle, I forgot to make sure that the file sending was implemented properly. @Livich fixed this in #254

@MBoretto Could we release a new version to include this fix?

@lviggiano
Copy link

lviggiano commented Jul 30, 2016

+1 for the release.

Got same issue as @daren-shan, bot working few days ago, not working anymore.
Hoping in a new release, since the only workaround I could see is to remove the webhook and use the getUpdates.

@MBoretto
Copy link
Collaborator

gonna release!

@lviggiano
Copy link

lviggiano commented Jul 30, 2016 via email

@lviggiano
Copy link

it's still not working for me

@noplanman
Copy link
Member

@lviggiano You have the latest version 0.35?

Try this and let us know what output you get please.

@daren-shan
Copy link

@lviggiano
Hi, i think main problem is self signed certificate,
if you use self signed cert try to use this way :

1- get a domain (you can get a free domain ( dot tk, dot ml, ...))
2-add your free domain as parked domain in your host (for example)
3- use CloudFlare service for SSL certificate.(its free)
4- setwebhook
after these steps my problem solved..

@mrkrotov
Copy link

Hi!

I'm using proxy at webhook script. And it seems there's problem with connection.
I can see no reaction from webhook in logs.

Before it, i setted bot by using link
https://api.telegram.org/bot[BOT TOKEN]/setWebhook?url=[BOT URL]
And got the right answer.

So, now after hours of searching, i decided to use set script.
The code is:
image

Switched on logging.
I've used different free proxy.

So in browser i've got error:
Telegram returned an invalid response!

And log says:
image

I'm using
PHP Version 7.0.29
cURL Information | 7.19.7

Server domain is under SSL by Let's Encrypt with Rating = A

What can be wrong?

@chuv1
Copy link

chuv1 commented Sep 22, 2018

@jacklul
Copy link
Collaborator

jacklul commented Sep 22, 2018

The proxy has to support https.
Even with that a lot FREE ones will fail because they are too slow or too flooded.

@mrkrotov
Copy link

The proxy has to support https.
Even with that a lot FREE ones will fail because they are too slow or too flooded.

Yes, unfortunately i didn't know about that)
So i found working https proxy and i'm using it in set and webhook scripts.
Set script returns "Webhook is already set".
Thanks!

But i'm still facing problem with webhook script.
It doesn't react on any messages from telegram.

The code is:
image

Have you checked https://api.telegram.org/bot[BOT_TOKEN]/getWebhookInfo ?
Yes, i've tried. It returns:
image

And i have no idea why there's "Connection timed out" error(

@jacklul
Copy link
Collaborator

jacklul commented Sep 24, 2018

Is your server located in Russia? If so then it won't work - you will have to relocate your server to different country, while using proxy will help you making API calls it won't help you in receiving updates from Telegram API as it won't be able to reach your server.

@mrkrotov
Copy link

Is your server located in Russia? If so then it won't work - you will have to relocate your server to different country, while using proxy will help you making API calls it won't help you in receiving updates from Telegram API as it won't be able to reach your server.

Yep, thanks!
I moved to Hetzner and it started to work)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests