protoncr / tourmaline

Simple Telegram bot library for Crystal
https://tourmaline.dev
MIT License
158 stars 38 forks source link

SSL error after sendingMessage #25

Closed christiankakesa closed 4 years ago

christiankakesa commented 4 years ago

Hi, I'm receiving the error below when sending message with my bot. I'm not sure if it's based on tourmaline, tourmaline's shards, or Crystal OpenSSL binding.

Can you help me understanding this error. Thanks.

E, [2020-05-25T00:05:02.950958000Z #14264]   ERROR -- crystal-run-main.tmp:tourmaline.client: SSL_read: error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac (OpenSSL::SSL::Error)
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/openssl/ssl/socket.cr:124:9 in 'unbuffered_read'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/io/buffered.cr:240:12 in 'fill_buffer'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/io/buffered.cr:103:7 in 'peek'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/io.cr:623:37 in 'gets'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/io.cr:582:5 in 'gets'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/http/client/response.cr:126:5 in 'from_io?'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/http/client.cr:588:5 in 'exec_internal_single'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/http/client.cr:574:5 in 'exec_internal'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/http/client.cr:570:5 in 'exec'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/http/client.cr:692:5 in 'exec:method:headers:body:path'
  from lib/tourmaline/src/tourmaline/client.cr:80:9 in 'request'
  from lib/tourmaline/src/tourmaline/client/core.cr:33:7 in 'get_updates'
  from lib/tourmaline/src/tourmaline/client/core.cr:27:5 in 'get_updates'
  from lib/tourmaline/src/tourmaline/client/core.cr:1177:21 in 'poll'
  from src/main.cr:19:1 in '__crystal_main'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/crystal/main.cr:105:5 in 'main_user_code'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/crystal/main.cr:91:7 in 'main'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/crystal/main.cr:114:3 in 'main'
  from __libc_start_main
  from _start
  from ???

[Error  ] [tourmaline.client] - SSL_read: error:1408F119:SSL routines:ssl3_get_record:decryption failed or bad record mac (OpenSSL::SSL::Error)
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/openssl/ssl/socket.cr:124:9 in 'unbuffered_read'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/io/buffered.cr:240:12 in 'fill_buffer'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/io/buffered.cr:103:7 in 'peek'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/io.cr:623:37 in 'gets'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/io.cr:582:5 in 'gets'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/http/client/response.cr:126:5 in 'from_io?'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/http/client.cr:588:5 in 'exec_internal_single'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/http/client.cr:574:5 in 'exec_internal'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/http/client.cr:570:5 in 'exec'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/http/client.cr:692:5 in 'exec:method:headers:body:path'
  from lib/tourmaline/src/tourmaline/client.cr:80:9 in 'request'
  from lib/tourmaline/src/tourmaline/client/core.cr:33:7 in 'get_updates'
  from lib/tourmaline/src/tourmaline/client/core.cr:27:5 in 'get_updates'
  from lib/tourmaline/src/tourmaline/client/core.cr:1177:21 in 'poll'
  from src/main.cr:19:1 in '__crystal_main'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/crystal/main.cr:105:5 in 'main_user_code'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/crystal/main.cr:91:7 in 'main'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/crystal/main.cr:114:3 in 'main'
  from __libc_start_main
  from _start
  from ???

E, [2020-05-25T00:05:02.956773000Z #14264]   ERROR -- crystal-run-main.tmp:tourmaline.client: SSL_write: I/O error (OpenSSL::SSL::Error)
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/openssl/ssl/socket.cr:137:7 in 'unbuffered_write'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/io/buffered.cr:218:5 in 'flush'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/http/client.cr:651:5 in 'send_request'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/http/client.cr:587:5 in 'exec_internal_single'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/http/client.cr:574:5 in 'exec_internal'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/http/client.cr:570:5 in 'exec'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/http/client.cr:692:5 in 'exec:method:headers:body:path'
  from lib/tourmaline/src/tourmaline/client.cr:80:9 in 'request'
  from lib/tourmaline/src/tourmaline/client/core.cr:33:7 in 'get_updates'
  from lib/tourmaline/src/tourmaline/client/core.cr:27:5 in 'get_updates'
  from lib/tourmaline/src/tourmaline/client/core.cr:1177:21 in 'poll'
  from src/main.cr:19:1 in '__crystal_main'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/crystal/main.cr:105:5 in 'main_user_code'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/crystal/main.cr:91:7 in 'main'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/crystal/main.cr:114:3 in 'main'
  from __libc_start_main
  from _start
  from ???
Caused by: SSL_write: Success (RuntimeError)

[Error  ] [tourmaline.client] - SSL_write: I/O error (OpenSSL::SSL::Error)
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/openssl/ssl/socket.cr:137:7 in 'unbuffered_write'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/io/buffered.cr:218:5 in 'flush'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/http/client.cr:651:5 in 'send_request'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/http/client.cr:587:5 in 'exec_internal_single'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/http/client.cr:574:5 in 'exec_internal'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/http/client.cr:570:5 in 'exec'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/http/client.cr:692:5 in 'exec:method:headers:body:path'
  from lib/tourmaline/src/tourmaline/client.cr:80:9 in 'request'
  from lib/tourmaline/src/tourmaline/client/core.cr:33:7 in 'get_updates'
  from lib/tourmaline/src/tourmaline/client/core.cr:27:5 in 'get_updates'
  from lib/tourmaline/src/tourmaline/client/core.cr:1177:21 in 'poll'
  from src/main.cr:19:1 in '__crystal_main'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/crystal/main.cr:105:5 in 'main_user_code'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/crystal/main.cr:91:7 in 'main'
  from /home/christian/opt/crystal-0.34.0-1/share/crystal/src/crystal/main.cr:114:3 in 'main'
  from __libc_start_main
  from _start
  from ???
Caused by: SSL_write: Success (RuntimeError)
watzon commented 4 years ago

Good to see someone else is seeing this happening too. Well not good, just good to know I'm not alone. As far as I can tell the bug has to be in Crystal itself, because there's nothing really fancy going on in the HTTP client, and even if there were this should not be happening.

I just need to figure out what the factors are that lead to this issue occurring so that I can duplicate it outside of Crystal. Any help in that area would be much appreciated.

watzon commented 4 years ago

@fenicks do you think you could post a minimal working (or in this case breaking) example of a bot that results in this error happening?

christiankakesa commented 4 years ago

@fenicks do you think you could post a minimal working (or in this case breaking) example of a bot that results in this error happening?

Yes, I will prepare a minimal working program this evening (from Paris).

watzon commented 4 years ago

@fenicks Much appreciated :) it could help narrow down the issue so I can get an issue report filed in the crystal-lang repo.

watzon commented 4 years ago

@fenicks I think I figured out the issue. Were you, by chance, trying to make requests from within a fiber? Go ahead and try the latest master branch update and see if it fixes your problem.

christiankakesa commented 4 years ago

@watzon I use parallel I my code which uses spawn (Fiber).

I didn't reproduce the bug because in my code I was using parallel but a dedicated HTTP::Client.

By using a new HTTP::Client or the ConnectionPool in the last commit it works.

Thanks.