Skip to content
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

communication not happening in Production mode #7

Closed
kirantpatil opened this issue Oct 5, 2017 · 42 comments
Closed

communication not happening in Production mode #7

kirantpatil opened this issue Oct 5, 2017 · 42 comments

Comments

@kirantpatil
Copy link

I tried in development mode and it is working fine but in production mode communication is not happening.

Please help me to resolve this issue.

My configuration details.

development: &dev
  secret_key_base: 3b7f55dd41146764804e122fc94b1e9b9fd86718659a219e8f0828135156dd0245165b215e29d740da4
  telegram:
    bot:
      token: 404717147:xxxxxyyyyzz-GETlwnnetV9olinux3xbrIvuuQjxtvSoz4
      username: kirantest_bot
      async: true
      # botan:
      #   token: botan_token
      #   # async: true

telegram_bot_app » Rails.application.routes.url_helpers.telegram_webhook_url
=> "https://172.104.41.236/telegram/404717147:xxxxxyyyyzz-GETlwnnetV9olinux3xbrIvuuQjxtvSoz4"

$ bin/rake telegram:bot:set_webhook RAILS_ENV=production

/home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:51: warning: constant ::Fixnum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:52: warning: constant ::Bignum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/core_ext/numeric/conversions.rb:138: warning: constant ::Fixnum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activejob-5.0.1/lib/active_job/arguments.rb:38: warning: constant ::Fixnum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activejob-5.0.1/lib/active_job/arguments.rb:38: warning: constant ::Bignum is deprecated
Running via Spring preloader in process 3455
Setting webhook for default...

fueb@localhost:~/telegram_bot_app$ puma -b 'ssl://172.104.41.236?key=webhook_pkey.pem&cert=webhook_cert.pem'

Puma starting in single mode...

  • Version 3.6.2 (ruby 2.4.1-p111), codename: Sleepy Sunday Serenity
  • Min threads: 5, max threads: 5
  • Environment: production
    /home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:51: warning: constant ::Fixnum is deprecated
    /home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:52: warning: constant ::Bignum is deprecated
    /home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/core_ext/numeric/conversions.rb:138: warning: constant ::Fixnum is deprecated
    /home/fueb/.rvm/gems/ruby-2.4.1/gems/activejob-5.0.1/lib/active_job/arguments.rb:38: warning: constant ::Fixnum is deprecated
    /home/fueb/.rvm/gems/ruby-2.4.1/gems/activejob-5.0.1/lib/active_job/arguments.rb:38: warning: constant ::Bignum is deprecated
  • Listening on ssl://172.104.41.236?key=webhook_pkey.pem&cert=webhook_cert.pem
    Use Ctrl-C to stop

Thanks.

@kirantpatil
Copy link
Author

ps -x output

3443 pts/0 Sl 0:00 spring server | telegram_bot_app | started 9 mins ago
3446 ? Ssl 0:02 spring app | telegram_bot_app | started 9 mins ago | production mode
3463 pts/0 Sl+ 0:03 puma 3.6.2 (ssl://172.104.41.236?key=webhook_pkey.pem&cert=webhook_cert.pem) [telegram_bot_app]

@kirantpatil
Copy link
Author

I am bit confused here, since I don't know how to upload the ssl public key to telegram.

I could get only how to generate ssl key link from telegram, https://core.telegram.org/bots/self-signed.

Am I right here ?

@kirantpatil
Copy link
Author

From the Telegram documents, I found below link.

https://core.telegram.org/bots/api#setwebhook

It talks of uploading the cert file as below, which I haven't done.

Parameters Type Required Description
url String Yes HTTPS url to send updates to. Use an empty string to remove webhook integration
certificate InputFile Optional Upload your public key certificate so that the root certificate in use can be checked. See our self-signed guide for details.
max_connections Integer Optional Maximum allowed number of simultaneous HTTPS connections to the webhook for update delivery, 1-100. Defaults to 40. Use lower values to limit the load on your bot‘s server, and higher values to increase your bot’s throughput.
allowed_updates Array of String Optional List the types of updates you want your bot to receive. For example, specify [“message”, “edited_channel_post”, “callback_query”] to only receive updates of these types. See Update for a complete list of available update types. Specify an empty list to receive all updates regardless of type (default). If not specified, the previous setting will be used.Please note that this parameter doesn't affect updates created before the call to the setWebhook, so unwanted updates may be received for a short period of time.

@printercu
Copy link
Member

Hi! I haven't tried self-issued certs, but have added param for it https://github.com/telegram-bot-rb/telegram-bot/blob/master/lib/tasks/telegram-bot.rake#L18. Try to set CERT envar when running set_webhook task, it should do the trick.

I also have never run puma with ssl, always used nginx as frontend. Please check that it works fine and you can access server via https in browser.

@kirantpatil
Copy link
Author

@printercu Thanks, I am getting new error after passing the CERT env when running set_webhook task for which I have created new issue.

@kirantpatil
Copy link
Author

@printercu, please let me know how are you configuring the https setup in your case ?

@printercu
Copy link
Member

You can comment out async: true and run rake task, and then uncomment it again, until I fix an issue. This task was created before async mode appeared.

@kirantpatil
Copy link
Author

Yes, now error does not appear, but server is not getting any message.

$ bin/rake telegram:bot:set_webhook RAILS_ENV=production CERT="webhook_cert.pem"
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:51: warning: constant ::Fixnum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:52: warning: constant ::Bignum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/core_ext/numeric/conversions.rb:138: warning: constant ::Fixnum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activejob-5.0.1/lib/active_job/arguments.rb:38: warning: constant ::Fixnum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activejob-5.0.1/lib/active_job/arguments.rb:38: warning: constant ::Bignum is deprecated
Running via Spring preloader in process 9974
Setting webhook for default...

@printercu
Copy link
Member

Does puma receive any other requests? I've tried https://172.104.41.236 and it's not working.

@printercu
Copy link
Member

Sorry, mentioned wrong issue in commit, reopen. Should be closing #8

@printercu printercu reopened this Oct 5, 2017
@kirantpatil
Copy link
Author

Yes, for me browser is showing "Unable to connect". Puma is not receiving any requests.

Please clarify my doubt. Why are you using nginx, since puma can server the requests ?

$ puma -b 'ssl://172.104.41.236?key=/home/fueb/server.key&cert=/home/fueb/server.crt'
Puma starting in single mode...

  • Version 3.6.2 (ruby 2.4.1-p111), codename: Sleepy Sunday Serenity
  • Min threads: 5, max threads: 5
  • Environment: production
    /home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:51: warning: constant ::Fixnum is deprecated
    /home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:52: warning: constant ::Bignum is deprecated
    /home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/core_ext/numeric/conversions.rb:138: warning: constant ::Fixnum is deprecated
    /home/fueb/.rvm/gems/ruby-2.4.1/gems/activejob-5.0.1/lib/active_job/arguments.rb:38: warning: constant ::Fixnum is deprecated
    /home/fueb/.rvm/gems/ruby-2.4.1/gems/activejob-5.0.1/lib/active_job/arguments.rb:38: warning: constant ::Bignum is deprecated
  • Listening on ssl://172.104.41.236?key=/home/fueb/server.key&cert=/home/fueb/server.crt
    Use Ctrl-C to stop

@kirantpatil
Copy link
Author

With below change, now puma is able to get request, but from telegram communication not happening.

$ puma -b 'ssl://0.0.0.0:3000?key=/home/fueb/server.key&cert=/home/fueb/server.crt'
Puma starting in single mode...

  • Version 3.6.2 (ruby 2.4.1-p111), codename: Sleepy Sunday Serenity
  • Min threads: 5, max threads: 5
  • Environment: production
    /home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:51: warning: constant ::Fixnum is deprecated
    /home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:52: warning: constant ::Bignum is deprecated
    /home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/core_ext/numeric/conversions.rb:138: warning: constant ::Fixnum is deprecated
    /home/fueb/.rvm/gems/ruby-2.4.1/gems/activejob-5.0.1/lib/active_job/arguments.rb:38: warning: constant ::Fixnum is deprecated
    /home/fueb/.rvm/gems/ruby-2.4.1/gems/activejob-5.0.1/lib/active_job/arguments.rb:38: warning: constant ::Bignum is deprecated
  • Listening on ssl://0.0.0.0:3000?key=/home/fueb/server.key&cert=/home/fueb/server.crt
    Use Ctrl-C to stop
$ tail -f telegram_bot_app/log/production.log 
[3e90fc1c-946a-4c90-936b-ad4769e8db95] activesupport (5.0.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
[3e90fc1c-946a-4c90-936b-ad4769e8db95] actionpack (5.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
[3e90fc1c-946a-4c90-936b-ad4769e8db95] rack (2.0.1) lib/rack/sendfile.rb:111:in `call'
[3e90fc1c-946a-4c90-936b-ad4769e8db95] actionpack (5.0.1) lib/action_dispatch/middleware/ssl.rb:84:in `call'
[3e90fc1c-946a-4c90-936b-ad4769e8db95] railties (5.0.1) lib/rails/engine.rb:522:in `call'
[3e90fc1c-946a-4c90-936b-ad4769e8db95] puma (3.6.2) lib/puma/configuration.rb:225:in `call'
[3e90fc1c-946a-4c90-936b-ad4769e8db95] puma (3.6.2) lib/puma/server.rb:578:in `handle_request'
[3e90fc1c-946a-4c90-936b-ad4769e8db95] puma (3.6.2) lib/puma/server.rb:415:in `process_client'
[3e90fc1c-946a-4c90-936b-ad4769e8db95] puma (3.6.2) lib/puma/server.rb:275:in `block in run'
[3e90fc1c-946a-4c90-936b-ad4769e8db95] puma (3.6.2) lib/puma/thread_pool.rb:116:in `block in spawn_thread'


I, [2017-10-06T06:21:54.853964 #20755]  INFO -- : [e60eb7ee-e995-483d-a8a1-11acf4421513] Started GET "/" for 106.51.68.123 at 2017-10-06 06:21:54 +0000
F, [2017-10-06T06:21:54.855351 #20755] FATAL -- : [e60eb7ee-e995-483d-a8a1-11acf4421513]   
F, [2017-10-06T06:21:54.855501 #20755] FATAL -- : [e60eb7ee-e995-483d-a8a1-11acf4421513] ActionController::RoutingError (No route matches [GET] "/"):
F, [2017-10-06T06:21:54.855598 #20755] FATAL -- : [e60eb7ee-e995-483d-a8a1-11acf4421513]   
F, [2017-10-06T06:21:54.855728 #20755] FATAL -- : [e60eb7ee-e995-483d-a8a1-11acf4421513] actionpack (5.0.1) lib/action_dispatch/middleware/debug_exceptions.rb:53:in `call'
[e60eb7ee-e995-483d-a8a1-11acf4421513] actionpack (5.0.1) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
[e60eb7ee-e995-483d-a8a1-11acf4421513] railties (5.0.1) lib/rails/rack/logger.rb:36:in `call_app'
[e60eb7ee-e995-483d-a8a1-11acf4421513] railties (5.0.1) lib/rails/rack/logger.rb:24:in `block in call'
[e60eb7ee-e995-483d-a8a1-11acf4421513] activesupport (5.0.1) lib/active_support/tagged_logging.rb:69:in `block in tagged'
[e60eb7ee-e995-483d-a8a1-11acf4421513] activesupport (5.0.1) lib/active_support/tagged_logging.rb:26:in `tagged'
[e60eb7ee-e995-483d-a8a1-11acf4421513] activesupport (5.0.1) lib/active_support/tagged_logging.rb:69:in `tagged'
[e60eb7ee-e995-483d-a8a1-11acf4421513] railties (5.0.1) lib/rails/rack/logger.rb:24:in `call'
[e60eb7ee-e995-483d-a8a1-11acf4421513] actionpack (5.0.1) lib/action_dispatch/middleware/request_id.rb:24:in `call'
[e60eb7ee-e995-483d-a8a1-11acf4421513] rack (2.0.1) lib/rack/method_override.rb:22:in `call'
[e60eb7ee-e995-483d-a8a1-11acf4421513] rack (2.0.1) lib/rack/runtime.rb:22:in `call'
[e60eb7ee-e995-483d-a8a1-11acf4421513] activesupport (5.0.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
[e60eb7ee-e995-483d-a8a1-11acf4421513] actionpack (5.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
[e60eb7ee-e995-483d-a8a1-11acf4421513] rack (2.0.1) lib/rack/sendfile.rb:111:in `call'
[e60eb7ee-e995-483d-a8a1-11acf4421513] actionpack (5.0.1) lib/action_dispatch/middleware/ssl.rb:84:in `call'
[e60eb7ee-e995-483d-a8a1-11acf4421513] railties (5.0.1) lib/rails/engine.rb:522:in `call'
[e60eb7ee-e995-483d-a8a1-11acf4421513] puma (3.6.2) lib/puma/configuration.rb:225:in `call'
[e60eb7ee-e995-483d-a8a1-11acf4421513] puma (3.6.2) lib/puma/server.rb:578:in `handle_request'
[e60eb7ee-e995-483d-a8a1-11acf4421513] puma (3.6.2) lib/puma/server.rb:415:in `process_client'
[e60eb7ee-e995-483d-a8a1-11acf4421513] puma (3.6.2) lib/puma/server.rb:275:in `block in run'
[e60eb7ee-e995-483d-a8a1-11acf4421513] puma (3.6.2) lib/puma/thread_pool.rb:116:in `block in spawn_thread'

screenshot from 2017-10-06 11 56 16

screenshot from 2017-10-06 11 57 21

@kirantpatil
Copy link
Author

I also did execute the curl command and still no communication from telegram bot.

$ curl -F "url=https://172.104.41.236:8443/telegram/404717147_AAEmW09G2OZMn-GETV9o3xbrIvQjxtvSoz4/webhooks/telegram" -F "certificate=/home/fueb/server.crt" https://api.telegram.org/bot404717147:AAEmW09G2OZMn-GETV9o3xbrIvQjxtvSoz4/setWebhook

{"ok":true,"result":true,"description":"Webhook was set"}

@printercu
Copy link
Member

Puma has not been accepting requests without :3000, because default https port is 443 and it requires root privileges to bind it.

Please clarify my doubt. Why are you using nginx, since puma can server the requests ?

I use nginx because it manages virtual hosts for me, and i can have multiple applications even on single domain on different subdomains. All of them can use standard ports (80/443), with multiple pumas you have to use different port for each instance.

With below change, now puma is able to get request, but from telegram communication not happening.

Since you've added port to address, url has changed, and you need to tell telegram to use new one. Have you run set_webhook task after this change? P.s. don't forget to disable async mode or use updated gem from master ;)

@kirantpatil
Copy link
Author

kirantpatil commented Oct 6, 2017

Now, I am using nginx and my configurations as below, but still no request from telegram.

\# Set application domain, to be able to run `rake telegram:bot:set_webhook`
  routes.default_url_options = {host: '172.104.41.236', protocol: 'https'}

I ran set_webhook task by disabling the async in secret.yml file.

I async mode enabled it again.

I did run the puma server with nginx and now I could see home page of rails but from telegram bot no requests made.

Edit:

[1] telegram_bot_app »  Rails.application.routes.url_helpers.telegram_webhook_url
=> "https://172.104.41.236/telegram/404717147_AAEmW09G2OZMn-GETV9o3xbrIvQjxtvSoz4"

screenshot from 2017-10-06 14 39 05

@printercu
Copy link
Member

$ curl -X POST 'https://172.104.41.236/telegram/404717147_AAEmW09G2OZMn-GETV9o3xbrIvQjxtvSoz4' -k

Fails with rails 500 error page.

@kirantpatil
Copy link
Author

Yes, that is correct since under production mode.

Here is my production.log file content, when execute that curl command


I, [2017-10-06T11:53:13.238532 #11328]  INFO -- : [0d27caaf-61b2-4c1b-b533-c9d0607f82dc] Started POST "/telegram/404717147_AAEmW09G2OZMn-GETV9o3xbrIvQjxtvSoz4" for 106.51.68.123 at 2017-10-06 11:53:13 +0000
I, [2017-10-06T11:53:13.239894 #11328]  INFO -- : [0d27caaf-61b2-4c1b-b533-c9d0607f82dc] Processing by TelegramWebhooksController#unsupported_payload_type
  Update: {}
I, [2017-10-06T11:53:13.251800 #11328]  INFO -- : [0d27caaf-61b2-4c1b-b533-c9d0607f82dc] Responded with message
I, [2017-10-06T11:53:13.252219 #11328]  INFO -- : [0d27caaf-61b2-4c1b-b533-c9d0607f82dc] Completed in 12ms
F, [2017-10-06T11:53:13.253954 #11328] FATAL -- : [0d27caaf-61b2-4c1b-b533-c9d0607f82dc]   
F, [2017-10-06T11:53:13.254068 #11328] FATAL -- : [0d27caaf-61b2-4c1b-b533-c9d0607f82dc] RuntimeError (Can not respond_with when chat is not present):
F, [2017-10-06T11:53:13.254185 #11328] FATAL -- : [0d27caaf-61b2-4c1b-b533-c9d0607f82dc]   
F, [2017-10-06T11:53:13.254278 #11328] FATAL -- : [0d27caaf-61b2-4c1b-b533-c9d0607f82dc] app/controllers/telegram_webhooks_controller.rb:104:in `action_missing'

@printercu
Copy link
Member

Seems like it means that this url is correct and app receives requests.

Seems like telegram refuses making requests to expired certificates:

image

Is this one is which you passed in set_webhook?

@kirantpatil
Copy link
Author

I am passing server.crt file.

$ bin/rake telegram:bot:set_webhook RAILS_ENV=production CERT="/home/fueb/server.crt"

@printercu
Copy link
Member

Does nginx use it?

@printercu
Copy link
Member

I've checked your cert from #8, it shows different info

image

@printercu
Copy link
Member

It's not necessary to run nginx, i thought you was almost done with puma, there was just set old url for webhook, when you changed port.

@kirantpatil
Copy link
Author

My nginx configuration.


server {
    listen 443 ssl;
    server_name 172.104.41.236;

    access_log /home/fueb/telegram_bot_app/log/access.log;
    error_log /home/fueb/telegram_bot_app/log/error.log;

    root /home/fueb/telegram_bot_app/public;

    ssl_certificate /home/fueb/server.crt;
    ssl_certificate_key /home/fueb/server.key;

    add_header Strict-Transport-Security “max-age=31536000”;

      try_files $uri/index.html $uri @namtaxi;

  location @namtaxi {
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $host;
    proxy_set_header X-Forwarded-Proto https;
    proxy_redirect off;
    proxy_pass http://namtaxi;
    }

  }

@printercu
Copy link
Member

I don't know why this certs are different. My suggestion is at least not to use expired certs, as one of them expired on 09/18, and other on 10/3.

@kirantpatil
Copy link
Author

I had other entries in nginx file, which I removed now and below is the certificate in my browser.

screenshot from 2017-10-06 18 50 00

@printercu
Copy link
Member

So you run set_webhook again with new cert and still no updates from telegram?

@kirantpatil
Copy link
Author

Yes, still no updates from telegram.

@printercu
Copy link
Member

I'll try to run bot with self-signed cert and come back with result later.

@kirantpatil
Copy link
Author

kirantpatil commented Oct 6, 2017 via email

@printercu
Copy link
Member

printercu commented Oct 9, 2017

Finally have checked everything. I've also had a problem, before found this guide on self-signed certs for telegram. The problem for me was that I haven't provided an ip when created certificate (just copied command from telegram's guide).

Here is list of command to run sample app from scratch:

cd /tmp
git clone https://github.com/telegram-bot-rb/telegram_bot_app.git
cd telegram_bot_app/
bundle install

cp config/secrets.yml.sample config/secrets.yml
nano config/secrets.yml
# configure bot for prod. Sample file aliases prod to dev.

nano config/environments/production.rb
# Add this line. Use 
# routes.default_url_options = {host: '%YOUR_IP_ADDR%', protocol: 'https', port: 8443}

# This is from telegram's guide.
# IMPORTANT! provide your ip address in CN field:
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=%YOUR_IP_ADDR%"

RAILS_ENV=production rake telegram:bot:set_webhook CERT=YOURPUBLIC.pem
# Make sure it said: `Setting webhook for default...`

RAILS_ENV=production puma -b 'ssl://0.0.0.0:8443?key=YOURPRIVATE.key&cert=YOURPUBLIC.pem'

If encounter any problem, try bot.get_webhook_info, it's result may contain useful debug info.

@kirantpatil
Copy link
Author

Thanks, I will check it with your steps and report it.

@kirantpatil
Copy link
Author

Where should I run this command.

bot.get_webhook_info

@kirantpatil
Copy link
Author

I followed your steps as below and still there is no communication.

fueb@localhost:~/telegram_bot_app$ RAILS_ENV=production rake telegram:bot:set_webhook CERT=gtt.pem
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:51: warning: constant ::Fixnum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:52: warning: constant ::Bignum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/core_ext/numeric/conversions.rb:138: warning: constant ::Fixnum is deprecated
Setting webhook for default...
fueb@localhost:~/telegram_bot_app$ RAILS_ENV=production puma -b 'ssl://0.0.0.0:8443?key=gtt.key&cert=gtt.pem'
[11503] Puma starting in cluster mode...
[11503] * Version 3.10.0 (ruby 2.4.1-p111), codename: Russell's Teapot
[11503] * Min threads: 4, max threads: 4
[11503] * Environment: production
[11503] * Process workers: 4
[11503] * Phased restart available
[11503] * Listening on ssl://0.0.0.0:8443?key=gtt.key&cert=gtt.pem
[11503] Use Ctrl-C to stop
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:51: warning: constant ::Fixnum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:52: warning: constant ::Bignum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:51: warning: constant ::Fixnum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:52: warning: constant ::Bignum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:51: warning: constant ::Fixnum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:52: warning: constant ::Bignum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:51: warning: constant ::Fixnum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:52: warning: constant ::Bignum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/core_ext/numeric/conversions.rb:138: warning: constant ::Fixnum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/core_ext/numeric/conversions.rb:138: warning: constant ::Fixnum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/core_ext/numeric/conversions.rb:138: warning: constant ::Fixnum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activesupport-5.0.1/lib/active_support/core_ext/numeric/conversions.rb:138: warning: constant ::Fixnum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activejob-5.0.1/lib/active_job/arguments.rb:38: warning: constant ::Fixnum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activejob-5.0.1/lib/active_job/arguments.rb:38: warning: constant ::Bignum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activejob-5.0.1/lib/active_job/arguments.rb:38: warning: constant ::Fixnum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activejob-5.0.1/lib/active_job/arguments.rb:38: warning: constant ::Bignum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activejob-5.0.1/lib/active_job/arguments.rb:38: warning: constant ::Fixnum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activejob-5.0.1/lib/active_job/arguments.rb:38: warning: constant ::Bignum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activejob-5.0.1/lib/active_job/arguments.rb:38: warning: constant ::Fixnum is deprecated
/home/fueb/.rvm/gems/ruby-2.4.1/gems/activejob-5.0.1/lib/active_job/arguments.rb:38: warning: constant ::Bignum is deprecated
[11503] - Worker 1 (pid: 11509) booted, phase: 0
[11503] - Worker 2 (pid: 11514) booted, phase: 0
[11503] - Worker 0 (pid: 11506) booted, phase: 0
[11503] - Worker 3 (pid: 11518) booted, phase: 0

[6] telegram_bot_app »  Rails.application.routes.url_helpers.telegram_webhook_url
=> "https://172.104.41.236/telegram/404717147_AAEmW09G2OZMn-GETV9o3xbrIvQjxtvSoz4"

@printercu
Copy link
Member

Please run Telegram.bot.get_webhook_info in production console

@kirantpatil
Copy link
Author

Yes, here it the output


[1] telegram_bot_app »  Telegram.bot.get_webhook_info
/home/fueb/.rvm/gems/ruby-2.4.1/gems/awesome_print-1.7.0/lib/awesome_print/formatters/base_formatter.rb:31: warning: constant ::Fixnum is deprecated
=> {
      "ok" => true,
  "result" => {
                       "url" => "https://172.104.41.236/telegram/404717147_AAEmW09G2OZMn-GETV9o3xbrIvQjxtvSoz4",
    "has_custom_certificate" => true,
      "pending_update_count" => 6,
           "last_error_date" => 1507620861,
        "last_error_message" => "SSL error {337047686, error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed}",
           "max_connections" => 40
  }
}

@printercu
Copy link
Member

printercu commented Oct 10, 2017

routines:tls_process_server_certificate:certificate verify failed

This means ssl certificate is not suitable for telegram. I had same error, when copied this command without changing:
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=%YOUR_IP_ADDR%". Make sure you provide your real ip address in the CN field.

@kirantpatil
Copy link
Author

Yes, I followed as you guided as below.

fueb@localhost:~/telegram_bot_app$ openssl req -newkey rsa:2048 -sha256 -nodes -keyout gtt.key -x509 -days 365 -out gtt.pem -subj "/C=IN/ST=Karnataka/L=Bengaluru/O=GTT Company/CN=172.104.41.236"
Generating a 2048 bit RSA private key
...................+++
........................................+++
writing new private key to 'gtt.key'
-----

@printercu
Copy link
Member

:( Can you please try all other fields untouched, may be this matters. This is the last resort to make it work. Do you run set_webhook and restart puma after each key generation?

@printercu
Copy link
Member

printercu commented Oct 10, 2017

"url" => "https://172.104.41.236/tel...
puma -b 'ssl://0.0.0.0:8443?

No port is provided in url. Please update default_url_options in production.rb

@kirantpatil
Copy link
Author

Yes, I corrected it, rerun seb_webook and puma. Now it started to work finally.

Thanks a lot @printercu.

@kirantpatil
Copy link
Author

Now it works with nginx and puma combination and standard port 443.

@anko20094
Copy link

Now it works with nginx and puma combination and standard port 443.

Hello, may I ask you share here configurations for:
1)Gemfile group :development;
2)Capfile file;
3)deploy.rb file
4)And how did you setted up on server(nginx, /etc/nginx/sites-available/default, puma service for your telegram bot, etc)
I'll be very appriciated for these.

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

3 participants