Rails - Mongrel Time out on file upload from phone - image

I have a mobile app built using Rhomobile. When I launch an image upload from the phone to the rails server I end up with timeout issues on larger pictures (2+ MBs). I get an error in Mongrel on server side (Rails 2.3.8) and a CURL timeout error on the phone side. Is the timeout an issue from the phone or from the mongrel server?
Mongrel error:
Wed Oct 19 09:07:05 -0500 2011: Error reading HTTP body: #<RuntimeError: Socket read returned insufficient data: 13515>
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/http_request.rb:107:in `read_socket'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/http_request.rb:86:in `read_body'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/http_request.rb:55:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:149:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:149:in `process_client'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `initialize'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `new'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:282:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `each'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.rb:281:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:212:in `run'
/usr/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
/usr/bin/mongrel_rails:19:in `load'
/usr/bin/mongrel_rails:19
Error in Rhomobile App:
Net| Operation finished with error 28: Timeout was reached
Net| CURLNetRequest: METHOD = [POST] URL = [http://www.mywebsite.com/updload/upload_image ] BODY = []
I use the AsyncHttp.upload_file command.

Related

Is there any way of uploading large files with the ruby google drive api?

I was trying to upload a very large file (15GB) to google drive using the ruby's google-api-client, but I get a transmission error. Reading the documentation suggest you should be able to make the upload resumable by allowing for retries. But the upload fails even when using the max number of retries. Below is my attempt. Does anyone have any experience with this? It seems there isn't any helpful info about the ruby version of the google client.
file = Google::Apis::DriveV2::File.new(title: zip_name,parents:[parent_folder])
uploaded_file = service.insert_file(file, upload_source: zip_name, content_type: 'application/zip',supports_all_drives:true,options: { retries: 2**24 })
This also fails with the V3 version of the API.
file = Google::Apis::DriveV3::File.new(title: zip_name,parents:[parent_folder])
uploaded_file = service.create_file(file, upload_source: zip_name, content_type: 'application/zip',supports_all_drives:true,options: { retries: 2**24 })
Both yield this error
C:/Ruby24-x64/lib/ruby/2.4.0/openssl/buffering.rb:324:in `syswrite': execution expired (Google::Apis::TransmissionError)
from C:/Ruby24-x64/lib/ruby/2.4.0/openssl/buffering.rb:324:in `do_write'
from C:/Ruby24-x64/lib/ruby/2.4.0/openssl/buffering.rb:342:in `write'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/httpclient-2.8.3/lib/httpclient/ssl_socket.rb:80:in `<<'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/httpclient-2.8.3/lib/httpclient/http.rb:582:in `dump_file'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/httpclient-2.8.3/lib/httpclient/http.rb:508:in `dump'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/httpclient-2.8.3/lib/httpclient/http.rb:962:in `dump'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/httpclient-2.8.3/lib/httpclient/session.rb:517:in `block in query'
from C:/Ruby24-x64/lib/ruby/2.4.0/timeout.rb:103:in `timeout'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/httpclient-2.8.3/lib/httpclient/session.rb:515:in `query'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/httpclient-2.8.3/lib/httpclient/session.rb:177:in `query'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/httpclient-2.8.3/lib/httpclient.rb:1242:in `do_get_block'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/httpclient-2.8.3/lib/httpclient.rb:1019:in `block in do_request'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/httpclient-2.8.3/lib/httpclient.rb:1133:in `protect_keep_alive_disconnected'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/httpclient-2.8.3/lib/httpclient.rb:1014:in `do_request'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/httpclient-2.8.3/lib/httpclient.rb:1104:in `follow_redirect'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/httpclient-2.8.3/lib/httpclient.rb:854:in `request'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/httpclient-2.8.3/lib/httpclient.rb:765:in `post'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/google-api-client-0.52.0/lib/google/apis/core/upload.rb:232:in `send_upload_command'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/google-api-client-0.52.0/lib/google/apis/core/upload.rb:258:in `execute_once'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/google-api-client-0.52.0/lib/google/apis/core/http_command.rb:113:in `block (2 levels) in execute'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/retriable-3.1.2/lib/retriable.rb:61:in `block in retriable'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/retriable-3.1.2/lib/retriable.rb:56:in `times'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/retriable-3.1.2/lib/retriable.rb:56:in `retriable'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/google-api-client-0.52.0/lib/google/apis/core/http_command.rb:110:in `block in execute'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/retriable-3.1.2/lib/retriable.rb:61:in `block in retriable'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/retriable-3.1.2/lib/retriable.rb:56:in `times'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/retriable-3.1.2/lib/retriable.rb:56:in `retriable'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/google-api-client-0.52.0/lib/google/apis/core/http_command.rb:102:in `execute'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/google-api-client-0.52.0/lib/google/apis/core/base_service.rb:366:in `execute_or_queue_command'
from C:/Ruby24-x64/lib/ruby/gems/2.4.0/gems/google-api-client-0.52.0/generated/google/apis/drive_v3/service.rb:918:in `create_file'
So I managed to solve this by changing the client options to have a longer timeout period.
service = Google::Apis::DriveV3::DriveService.new
service.authorization = authorize('drive_token.yaml',Google::Apis::DriveV3::AUTH_DRIVE)
service.client_options.send_timeout_sec=12000
service.client_options.open_timeout_sec=12000
service.client_options.read_timeout_sec=12000

"fog openstack" authentification error

Trying to connect locally deployed openstack (pike) with fog.
Firstly, curl connection works well with the command:
https://hastebin.com/fihojuqize.scala
With this in mind, i've created fog credentials file: https://hastebin.com/hexanixucu.scala and run
fog openstack
Compute[:openstack].servers
This leads to an error like (full text here)
:status => 302
:status_line => "HTTP/1.1 302 Found\r\n"
from /var/lib/gems/2.3.0/gems/excon-0.60.0/lib/excon/middlewares/expects.rb:7:in `response_call'
from /var/lib/gems/2.3.0/gems/excon-0.60.0/lib/excon/middlewares/response_parser.rb:9:in `response_call'
from /var/lib/gems/2.3.0/gems/excon-0.60.0/lib/excon/connection.rb:414:in `response'
from /var/lib/gems/2.3.0/gems/excon-0.60.0/lib/excon/connection.rb:263:in `request'
from /var/lib/gems/2.3.0/gems/fog-core-1.45.0/lib/fog/core/connection.rb:81:in `request'
from /var/lib/gems/2.3.0/gems/fog-openstack-0.1.23/lib/fog/openstack.rb:610:in `get_version'
from /var/lib/gems/2.3.0/gems/fog-openstack-0.1.23/lib/fog/openstack.rb:583:in `get_supported_microversion'
from /var/lib/gems/2.3.0/gems/fog-openstack-0.1.23/lib/fog/openstack/core.rb:122:in `set_microversion'
from /var/lib/gems/2.3.0/gems/fog-openstack-0.1.23/lib/fog/openstack/core.rb:212:in `authenticate'
from /var/lib/gems/2.3.0/gems/fog-openstack-0.1.23/lib/fog/compute/openstack.rb:397:in `initialize'
from /var/lib/gems/2.3.0/gems/fog-core-1.45.0/lib/fog/core/service.rb:115:in `new'
from /var/lib/gems/2.3.0/gems/fog-core-1.45.0/lib/fog/core/service.rb:115:in `new'
from /var/lib/gems/2.3.0/gems/fog-core-1.45.0/lib/fog/core/services_mixin.rb:16:in `new'
from /var/lib/gems/2.3.0/gems/fog-core-1.45.0/lib/fog/compute.rb:54:in `new'
from /var/lib/gems/2.3.0/gems/fog-core-1.45.0/lib/fog/core/services_mixin.rb:4:in `[]'
from (irb):1:in `<top (required)>'
from /var/lib/gems/2.3.0/gems/fog-1.42.0/bin/fog:76:in `block in <top (required)>'
from /var/lib/gems/2.3.0/gems/fog-1.42.0/bin/fog:76:in `catch'
from /var/lib/gems/2.3.0/gems/fog-1.42.0/bin/fog:76:in `<top (required)>'
from /usr/local/bin/fog:23:in `load'
from /usr/local/bin/fog:23:in `<main>'
First request to "/identity/v3/auth/tokens" was complete, but overall result is bad..
Worth to be mentioned - i've cntlm proxy configured.
Export your openrc file which contains authentication information like this
​export OS_USERNAME=admin
​export OS_PASSWORD=ADMIN_PASS
​export OS_TENANT_NAME=admin
​export OS_AUTH_URL=http://controller:35357/v3.0

Unable to connect using net/ftp in ruby

I am getting following error when I am trying to connect the FTP server
ftp = Net::FTP::new("example.sg","username","password")
Errno::ECONNREFUSED: Connection refused - Connection refused
from org/jruby/ext/socket/RubyTCPSocket.java:121:in `initialize'
from org/jruby/RubyIO.java:876:in `new'
from org/jruby/ext/socket/RubyTCPSocket.java:147:in `open'
from /opt/jruby/lib/ruby/1.8/net/ftp.rb:159:in `open_socket'
from /opt/jruby/lib/ruby/1.8/net/ftp.rb:175:in `connect'
from /opt/jruby/lib/ruby/1.8/monitor.rb:191:in `mon_synchronize'
from /opt/jruby/lib/ruby/1.8/net/ftp.rb:174:in `connect'
from /opt/jruby/lib/ruby/1.8/net/ftp.rb:136:in `initialize'
from (irb):7:in `evaluate'
from org/jruby/RubyKernel.java:1083:in `eval'
from /opt/jruby/lib/ruby/1.8/irb.rb:158:in `eval_input'
from /opt/jruby/lib/ruby/1.8/irb.rb:271:in `signal_status'
from /opt/jruby/lib/ruby/1.8/irb.rb:155:in `eval_input'
from org/jruby/RubyKernel.java:1410:in `loop'
from org/jruby/RubyKernel.java:1183:in `catch'
from /opt/jruby/lib/ruby/1.8/irb.rb:154:in `eval_input'
from /opt/jruby/lib/ruby/1.8/irb.rb:71:in `start'
from org/jruby/RubyKernel.java:1183:in `catch'
from /opt/jruby/lib/ruby/1.8/irb.rb:70:in `start'
from /opt/jruby/bin/jirb:13:in `(root)
I am able to access the same website from a browser using ftp://example.sg.
Any ideas why net/ftp would have issues accessing the site?
Works using JRuby 1.7.4:
Welcome to the JRuby IRB Console [1.7.4 (1.9.3)]
irb(main):001:0> require 'net/ftp'
true
irb(main):002:0> ftp = Net::FTP.new('ftp.ruby-lang.org', 'anonymous', '')
#<Net::FTP:0x4e2d4656 #mon_count=0, #mon_owner=nil, #logged_in=true, #sock=#<TCPSocket:fd19>, #last_response="200 Switching to Binary mode.\n", #last_response_code="200", #passive=false, #resume=false, #binary=true, #debug_mode=false, #welcome="230 Login successful.\n", #mon_mutex=#<Mutex:0x7e64e032>>
irb(main):003:0> ftp.list
["drwxrwxr-x 5 106 111 4096 Dec 25 23:42 pub"]
Is it working for you if you try ruby-lang.org site?
I see that you used Net::FTP::new instead of Net::FTP.new, but it shouldn't matter :-)

Watir tests fail when running in background under windows 8

I'm running Watir tests in firefox using a jenkins slave installed as service under windows 8 in virtual box.
Testcases include two tests. When I run them manually, everything is fine. When jenkins runs them, the first test always succeeds, and the second always fails with exception:Net::ReadTimeout: Net::ReadTimeout.
I have tried different combinations of test code and begin/rescue blocks, but everytime the exception is caused by browser object methods:
#browser.goto
#browser.execute_script
#browser.wait_until_present
#browser.close
...
Setup and teardown are:
def teardown
#browser.close
end
def setup
profile = Selenium::WebDriver::Firefox::Profile.new
profile.add_extension #extension_path
#browser = Watir::Browser.new :firefox, :profile => profile
end
gems versions:
watir (4.0.2)
selenium-webdriver (2.33.0)
I have also tried to run service under system account with desktop interaction enabled and under local user account.
One of error logs:
> Net::ReadTimeout: Net::ReadTimeout
C:/Ruby200-x64/lib/ruby/2.0.0/net/protocol.rb:158:in `rescue in rbuf_fill'
C:/Ruby200-x64/lib/ruby/2.0.0/net/protocol.rb:152:in `rbuf_fill'
C:/Ruby200-x64/lib/ruby/2.0.0/net/protocol.rb:134:in `readuntil'
C:/Ruby200-x64/lib/ruby/2.0.0/net/protocol.rb:144:in `readline'
C:/Ruby200-x64/lib/ruby/2.0.0/net/http/response.rb:39:in `read_status_line'
C:/Ruby200-x64/lib/ruby/2.0.0/net/http/response.rb:28:in `read_new'
C:/Ruby200-x64/lib/ruby/2.0.0/net/http.rb:1406:in `block in transport_request'
C:/Ruby200-x64/lib/ruby/2.0.0/net/http.rb:1403:in `catch'
C:/Ruby200-x64/lib/ruby/2.0.0/net/http.rb:1403:in `transport_request'
C:/Ruby200-x64/lib/ruby/2.0.0/net/http.rb:1376:in `request'
C:/Ruby200-x64/lib/ruby/2.0.0/net/http.rb:1369:in `block in request'
C:/Ruby200-x64/lib/ruby/2.0.0/net/http.rb:852:in `start'
C:/Ruby200-x64/lib/ruby/2.0.0/net/http.rb:1367:in `request'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/default.rb:83:in `response_for'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/default.rb:39:in `request'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/http/common.rb:40:in `call'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/bridge.rb:629:in `raw_execute'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/bridge.rb:607:in `execute'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/remote/bridge.rb:195:in `quit'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/firefox/bridge.rb:55:in `quit'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/selenium-webdriver-2.33.0/lib/selenium/webdriver/common/driver.rb:168:in `quit'
C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/watir-webdriver-0.6.4/lib/watir-webdriver/browser.rb:135:in `close'
C:/jenkins/workspace/tests_matrix/TEST_BROWSER/firefox/TEST_OS/windows8/build_script_win/tests/test_case2.rb:173:in `teardown'
C:/Ruby200-x64/lib/ruby/2.0.0/minitest/unit.rb:1316:in `block in run'
C:/Ruby200-x64/lib/ruby/2.0.0/minitest/unit.rb:1314:in `each'
C:/Ruby200-x64/lib/ruby/2.0.0/minitest/unit.rb:1314:in `run'
C:/Ruby200-x64/lib/ruby/2.0.0/test/unit/testcase.rb:17:in `run'
C:/Ruby200-x64/lib/ruby/2.0.0/minitest/unit.rb:919:in `block in _run_suite'
C:/Ruby200-x64/lib/ruby/2.0.0/minitest/unit.rb:912:in `map'
C:/Ruby200-x64/lib/ruby/2.0.0/minitest/unit.rb:912:in `_run_suite'
C:/Ruby200-x64/lib/ruby/2.0.0/test/unit.rb:657:in `block in _run_suites'
C:/Ruby200-x64/lib/ruby/2.0.0/test/unit.rb:655:in `each'
C:/Ruby200-x64/lib/ruby/2.0.0/test/unit.rb:655:in `_run_suites'
C:/Ruby200-x64/lib/ruby/2.0.0/minitest/unit.rb:867:in `_run_anything'
C:/Ruby200-x64/lib/ruby/2.0.0/minitest/unit.rb:1060:in `run_tests'
C:/Ruby200-x64/lib/ruby/2.0.0/minitest/unit.rb:1047:in `block in _run'
C:/Ruby200-x64/lib/ruby/2.0.0/minitest/unit.rb:1046:in `each'
C:/Ruby200-x64/lib/ruby/2.0.0/minitest/unit.rb:1046:in `_run'
C:/Ruby200-x64/lib/ruby/2.0.0/minitest/unit.rb:1035:in `run'
C:/Ruby200-x64/lib/ruby/2.0.0/test/unit.rb:21:in `run'
C:/Ruby200-x64/lib/ruby/2.0.0/test/unit.rb:774:in `run'
C:/Ruby200-x64/lib/ruby/2.0.0/test/unit.rb:834:in `run'
C:/Ruby200-x64/lib/ruby/2.0.0/test/unit.rb:838:in `run'
C:/Users/test/AppData/Local/Temp/hudson2953103359547849695.sh:4:in `<main>'
I run into the Net::ReadTimeout error, too, and tried hard to fix it by refresh the browser after catching the Net::ReadTimeout error, like this:
begin
#browser.goto WEBSITE
rescue Net::ReadTimeout
#browser.refresh
sleep 1 unless #browser.ready_state == "complete"
end
I think if you post the test case code, maybe it will help to reach the solution.

Watir Webdriver ECONNRESET errors

I am getting this error
C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:141:in `read_nonblock': An existing connection was forcibly closed by the remote host. (Errno::ECONNRESET)
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:141:in `rbuf_fill'
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:122:in `readuntil'
from C:/Ruby193/lib/ruby/1.9.1/net/protocol.rb:132:in `readline'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:2562:in `read_status_line'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:2551:in `read_new'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1319:in `block in transport_request'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1316:in `catch'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1316:in `transport_request'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1293:in `request'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:1064:in `head'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/chrome/service.rb:63:in `block in stop'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:745:in `start'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:557:in `start'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/chrome/service.rb:59:in `stop'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/chrome/bridge.rb:50:in `quit'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.24.0/lib/selenium/webdriver/common/driver.rb:166:in `quit'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/watir-webdriver-0.6.1/lib/watir-webdriver/browser.rb:87:in `close'
from test_google.rb:9:in `block in <main>'
from test_google.rb:5:in `times'
from test_google.rb:5:in `<main>'
whenever I run tests successively. I believe it is a webdriver/selenium bug, but would like if someone could help me fix or determine the cause.
Here is some code you can try running in irb:
20.times { b = Watir::Browser.new :chrome; b.goto "http://google.com"; p b.div.exists?; b.close;}
EDIT: I updated my ChromeDriver and do not receive the error for the above code.
In order to fix this try updating your Chrome Driver: http://code.google.com/p/chromedriver/downloads/list

Resources