I've created telegram bot on Java with rubenlagus api.And now I can't setup webhook. I know these rules for webhook:
*Supports IPv4, IPv6 is currently not supported for Webhooks.
*Accepts incoming POSTs from 149.154.167.197-233 on port 443,80,88 or 8443.
*Is able to handle TLS1.0+ HTTPS-traffic.
*Provides a supported, non-wildcard, verified or self-signed certificate.
*Uses a CN or SAN that matches the domain you’ve supplied on setup.
*Supplies all intermediate certificates to complete a verification chain.
I have a domain name with verified ssl certificate.Qualys test shows A+ rank.Server Supports IPv4. 443 port is listening. And server accepts incoming POSTs from 149.154.167.197-233 on port 443. I use this rubenlagus api method for creating TelegramApi
private static TelegramBotsApi createNoSelfSignedTelegramBotsApi() throws TelegramApiException {
return new TelegramBotsApi(
"src/main/resources/server.jks",//path to KeyStore for the server
"myPassword", //Key store password for the serve
"https://example.com:443", //External url
"https://localhost:443"); //Internal url
}
I've obtained server.jks via these commands
- openssl pkcs12 -export -in mydomain.net.crt -inkey mydomain.key > keypair.p12
- keytool -importkeystore -srckeystore keypair.p12 -destkeystore server.jks -srcstoretype pkcs12
This is my code:
ApiContextInitializer.init();
TelegramBotsApi botsApi = new TelegramBotsApi(
"src/main/resources/server.jks",
"mypassword",
"https://example.com:443",
"https://localhost:443");
BotHook webhookBot = new BotHook(options);
botsApi.registerBot(webhookBot);
When i start program, i recieve this
Jul 28, 2018 3:27:59 PM org.glassfish.grizzly.http.server.NetworkListener start
INFO: Started listener bound to [localhost:443]
Jul 28, 2018 3:27:59 PM org.glassfish.grizzly.http.server.HttpServer start
INFO: [HttpServer] Started.
But bot don't work.I see this in server's logs:
2018/07/29 15:08:43 [error] 1166#1166: *453 openat() "/var/www/www->root/data/www/example.net/callback/WebhookClass failed (2: No such file or >directory), client: 149.154.167.227, server: example.net request: "POST >/callback/WebhookClass HTTP/1.1", host: "example.net"
It seems like Grizzly can't handle http request. When i'm trying to check it via this curl command
curl -X POST -i http://217.0.0.1:443/callback
I recieve this
curl: (7) Failed to connect to 217.0.0.1 port 443: Connection timed out
I checked many times all parameters passed in TelegramBotsApi constructor.