Hi, I'm using local API to upload files to telegram, but when it comes to large files (larger than standard, no local) it starts giving an error Net::ReadTimeout with #<TCPSocket:(closed)>
Here's a sample code that I use to upload files.
Telegram::Bot::Client.run(token, url:'http://127.0.0.1:8081') do |bot|#, url:'http://127.0.0.1:8081'
p "t"
p bot.api.send_document(chat_id:chat__id,
document:Faraday::UploadIO.new("200_mb_file.7z", "7z")
)
p "fin"
end
If you replace Faraday::UploadIO.new("200_mb_file.7z", "7z") with Fadaday::FilePart with a large timeout Faraday::FilePart.new("200_mb_file.7z", "7z",nil,{:timeout => 600,:open_timeout => 600}) then it eventually crash BUT file probably will be uploaded bc of local API
As far as I understand from the tests, the local API remembers that the file upload was started and will still upload the file even if the code fails. I also tried to start uploading the file again after rebooting the PC when the file was not fully uploaded , when I started it I found that the file uploaded faster than usual but still with error, it seems that telegram was still waiting for other parts of the file.
C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/net-protocol-0.2.2/lib/net/protocol.rb:229:in `rbuf_fill': Net::ReadTimeout with #<TCPSocket:(closed)> (Faraday::TimeoutError)
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/net-protocol-0.2.2/lib/net/protocol.rb:199:in `readuntil'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/net-protocol-0.2.2/lib/net/protocol.rb:209:in `readline'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/net-http-0.4.0/lib/net/http/response.rb:158:in `read_status_line'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/net-http-0.4.0/lib/net/http/response.rb:147:in `read_new'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/net-http-0.4.0/lib/net/http.rb:2342:in `block in transport_request'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/net-http-0.4.0/lib/net/http.rb:2333:in `catch'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/net-http-0.4.0/lib/net/http.rb:2333:in `transport_request'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/net-http-0.4.0/lib/net/http.rb:2306:in `request'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/faraday-net_http-3.0.2/lib/faraday/adapter/net_http.rb:113:in `block in request_with_wrapped_block'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/net-http-0.4.0/lib/net/http.rb:1570:in `start'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/faraday-net_http-3.0.2/lib/faraday/adapter/net_http.rb:112:in `request_with_wrapped_block'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/faraday-net_http-3.0.2/lib/faraday/adapter/net_http.rb:102:in `perform_request'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/faraday-net_http-3.0.2/lib/faraday/adapter/net_http.rb:66:in `block in call'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/faraday-2.7.12/lib/faraday/adapter.rb:45:in `connection'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/faraday-net_http-3.0.2/lib/faraday/adapter/net_http.rb:65:in `call'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/faraday-2.7.12/lib/faraday/request/url_encoded.rb:25:in `call'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/faraday-multipart-1.0.4/lib/faraday/multipart/middleware.rb:28:in `call'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/faraday-2.7.12/lib/faraday/rack_builder.rb:153:in `build_response'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/faraday-2.7.12/lib/faraday/connection.rb:444:in `run_request'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/faraday-2.7.12/lib/faraday/connection.rb:280:in `post'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/telegram-bot-ruby-1.0.0/lib/telegram/bot/api.rb:59:in `call'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/telegram-bot-ruby-1.0.0/lib/telegram/bot/api.rb:46:in `method_missing'
from c:/Users/alefi/Downloads/pixiv/test_folder/upload_test.rb:7:in `block in <main>'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/telegram-bot-ruby-1.0.0/lib/telegram/bot/client.rb:20:in `run'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/telegram-bot-ruby-1.0.0/lib/telegram/bot/client.rb:10:in `run'
from c:/Users/alefi/Downloads/pixiv/test_folder/upload_test.rb:5:in `<main>'
C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/net-protocol-0.2.2/lib/net/protocol.rb:229:in `rbuf_fill': Net::ReadTimeout with #<TCPSocket:(closed)> (Net::ReadTimeout)
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/net-protocol-0.2.2/lib/net/protocol.rb:199:in `readuntil'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/net-protocol-0.2.2/lib/net/protocol.rb:209:in `readline'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/net-http-0.4.0/lib/net/http/response.rb:158:in `read_status_line'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/net-http-0.4.0/lib/net/http/response.rb:147:in `read_new'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/net-http-0.4.0/lib/net/http.rb:2342:in `block in transport_request'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/net-http-0.4.0/lib/net/http.rb:2333:in `catch'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/net-http-0.4.0/lib/net/http.rb:2333:in `transport_request'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/net-http-0.4.0/lib/net/http.rb:2306:in `request'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/faraday-net_http-3.0.2/lib/faraday/adapter/net_http.rb:113:in `block in request_with_wrapped_block'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/net-http-0.4.0/lib/net/http.rb:1570:in `start'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/faraday-net_http-3.0.2/lib/faraday/adapter/net_http.rb:112:in `request_with_wrapped_block'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/faraday-net_http-3.0.2/lib/faraday/adapter/net_http.rb:102:in `perform_request'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/faraday-net_http-3.0.2/lib/faraday/adapter/net_http.rb:66:in `block in call'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/faraday-2.7.12/lib/faraday/adapter.rb:45:in `connection'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/faraday-net_http-3.0.2/lib/faraday/adapter/net_http.rb:65:in `call'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/faraday-2.7.12/lib/faraday/request/url_encoded.rb:25:in `call'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/faraday-multipart-1.0.4/lib/faraday/multipart/middleware.rb:28:in `call'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/faraday-2.7.12/lib/faraday/rack_builder.rb:153:in `build_response'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/faraday-2.7.12/lib/faraday/connection.rb:444:in `run_request'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/faraday-2.7.12/lib/faraday/connection.rb:280:in `post'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/telegram-bot-ruby-1.0.0/lib/telegram/bot/api.rb:59:in `call'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/telegram-bot-ruby-1.0.0/lib/telegram/bot/api.rb:46:in `method_missing'
from c:/Users/alefi/Downloads/pixiv/test_folder/upload_test.rb:7:in `block in <main>'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/telegram-bot-ruby-1.0.0/lib/telegram/bot/client.rb:20:in `run'
from C:/Users/alefi/.local/share/gem/ruby/3.2.0/gems/telegram-bot-ruby-1.0.0/lib/telegram/bot/client.rb:10:in `run'
from c:/Users/alefi/Downloads/pixiv/test_folder/upload_test.rb:5:in `<main>'
Am i doing it wrong way? Should i open a new Thread for every large file where i catch error and do nothing?
Hi, I'm using local API to upload files to telegram, but when it comes to large files (larger than standard, no local) it starts giving an error
Net::ReadTimeout with #<TCPSocket:(closed)>
Here's a sample code that I use to upload files.If you replace
Faraday::UploadIO.new("200_mb_file.7z", "7z")
withFadaday::FilePart
with a large timeoutFaraday::FilePart.new("200_mb_file.7z", "7z",nil,{:timeout => 600,:open_timeout => 600})
then it eventually crash BUT file probably will be uploaded bc of local APIAs far as I understand from the tests, the local API remembers that the file upload was started and will still upload the file even if the code fails. I also tried to start uploading the file again after rebooting the PC when the file was not fully uploaded , when I started it I found that the file uploaded faster than usual but still with error, it seems that telegram was still waiting for other parts of the file.
Am i doing it wrong way? Should i open a new Thread for every large file where i catch error and do nothing?