Connection refused to s3 storage - ruby

I m trying to upload a file through attachment fu to amazon s3 storage using the following code :-
has_attachment :storage => :s3,
:content_type =>
['audio/mp3','audio/flac','audio/wav'],
:path_prefix => '#####',
:output_path => '######',
:processor => :none
But get the following error:-
Connection refused - connect(2)
Application Trace | Framework Trace | Full Trace
/usr/lib/ruby/1.8/net/http.rb:560:in `initialize'
/usr/lib/ruby/1.8/net/http.rb:560:in `open'
/usr/lib/ruby/1.8/net/http.rb:560:in `connect'
/usr/lib/ruby/1.8/timeout.rb:53:in `timeout'
/usr/lib/ruby/1.8/timeout.rb:93:in `timeout'
/usr/lib/ruby/1.8/net/http.rb:560:in `connect'
/usr/lib/ruby/1.8/net/http.rb:553:in `do_start'
/usr/lib/ruby/1.8/net/http.rb:542:in `start'
vendor/plugins/aws-s3/lib/aws/s3/connection.rb:52:in `request'
vendor/plugins/aws-s3/lib/aws/s3/base.rb:69:in `request'
vendor/plugins/aws-s3/lib/aws/s3/base.rb:88:in `put'
vendor/plugins/aws-s3/lib/aws/s3/object.rb:241:in `store'
vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu/backends/s3_backend.rb:294:in `save_to_storage'
vendor/plugins/attachment_fu/lib/technoweenie/attachment_fu.rb:369:in `after_process_attachment'
vendor/rails/activerecord/lib/active_record/callbacks.rb:307:in `send'
vendor/rails/activerecord/lib/active_record/callbacks.rb:307:in `callback'
vendor/rails/activerecord/lib/active_record/callbacks.rb:304:in `each'
vendor/rails/activerecord/lib/active_record/callbacks.rb:304:in `callback'
vendor/rails/activerecord/lib/active_record/callbacks.rb:214:in `create_or_update'
vendor/rails/activerecord/lib/active_record/base.rb:1973:in `save_without_validation'
vendor/rails/activerecord/lib/active_record/validations.rb:927:in `save_without_transactions'
vendor/rails/activerecord/lib/active_record/transactions.rb:108:in `save'
vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:66:in `transaction'
vendor/rails/activerecord/lib/active_record/transactions.rb:80:in `transaction'
vendor/rails/activerecord/lib/active_record/transactions.rb:100:in `transaction'
vendor/rails/activerecord/lib/active_record/transactions.rb:108:in `save'
vendor/rails/activerecord/lib/active_record/transactions.rb:120:in `rollback_active_record_state!'
vendor/rails/activerecord/lib/active_record/transactions.rb:108:in `save'
vendor/rails/activerecord/lib/active_record/base.rb:2035:in `update_attributes'
app/models/track_file.rb:45:in `upload'
app/controllers/media_controller.rb:202:in `track_update'
app/controllers/application.rb:157:in `access_session_value_in_models'

like ruby is stating you cannot connect to the s3 server for some reason.
make some connectivity test on your server using the telnet command.
i.e. telnet s3.amazonaws.com 80

Related

"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

Failure to upload file to S3 using Ruby

I'm uploading a collection of files to S3 (53 files) but towards the end, around 45 files, this starts to happen:
Connection reset by peer
E, [2015-05-07T10:43:03.361617 #8542] ERROR -- : /home/mauricio/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/openssl/buffering.rb:326:in `syswrite'
/home/mauricio/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/openssl/buffering.rb:326:in `do_write'
/home/mauricio/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/openssl/buffering.rb:344:in `write'
/home/mauricio/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/net/protocol.rb:211:in `write0'
/home/mauricio/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/net/protocol.rb:185:in `block in write'
/home/mauricio/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/net/protocol.rb:202:in `writing'
/home/mauricio/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/net/protocol.rb:184:in `write'
/home/mauricio/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/net/http/generic_request.rb:187:in `send_request_with_body'
/home/mauricio/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/net/http/generic_request.rb:120:in `exec'
/home/mauricio/.rvm/gems/ruby-2.2.0/gems/aws-sdk-v1-1.64.0/lib/aws/core/http/patch.rb:27:in `block in new_transport_request'
/home/mauricio/.rvm/gems/ruby-2.2.0/gems/aws-sdk-v1-1.64.0/lib/aws/core/http/patch.rb:26:in `catch'
/home/mauricio/.rvm/gems/ruby-2.2.0/gems/aws-sdk-v1-1.64.0/lib/aws/core/http/patch.rb:26:in `new_transport_request'
/home/mauricio/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/net/http.rb:1383:in `request'
/home/mauricio/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/net/http.rb:1376:in `block in request'
/home/mauricio/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/net/http.rb:853:in `start'
/home/mauricio/.rvm/rubies/ruby-2.2.0/lib/ruby/2.2.0/net/http.rb:1374:in `request'
/home/mauricio/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.3/lib/httparty/request.rb:98:in `perform'
/home/mauricio/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.3/lib/httparty.rb:539:in `perform_request'
/home/mauricio/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.3/lib/httparty.rb:501:in `put'
/home/mauricio/.rvm/gems/ruby-2.2.0/gems/httparty-0.13.3/lib/httparty.rb:589:in `put'
/home/mauricio/.rvm/gems/ruby-2.2.0/bundler/gems/neat-cli-44b0902e2c95/lib/neat_cli/client.rb:318:in `block in finish_upload'
/home/mauricio/.rvm/gems/ruby-2.2.0/bundler/gems/neat-cli-44b0902e2c95/lib/neat_cli/client.rb:698:in `call'
/home/mauricio/.rvm/gems/ruby-2.2.0/bundler/gems/neat-cli-44b0902e2c95/lib/neat_cli/client.rb:698:in `validating_response'
/home/mauricio/.rvm/gems/ruby-2.2.0/bundler/gems/neat-cli-44b0902e2c95/lib/neat_cli/client.rb:317:in `finish_upload'
/home/mauricio/.rvm/gems/ruby-2.2.0/bundler/gems/neat-cli-44b0902e2c95/lib/neat_cli/client.rb:327:in `v4_upload'
/home/mauricio/projects/ruby/spi-test/lib/spitest/webapp.rb:17:in `block in upload'
/home/mauricio/.rvm/gems/ruby-2.2.0/gems/retriable-2.0.2/lib/retriable.rb:53:in `block in retriable'
/home/mauricio/.rvm/gems/ruby-2.2.0/gems/retriable-2.0.2/lib/retriable.rb:48:in `each'
/home/mauricio/.rvm/gems/ruby-2.2.0/gems/retriable-2.0.2/lib/retriable.rb:48:in `with_index'
/home/mauricio/.rvm/gems/ruby-2.2.0/gems/retriable-2.0.2/lib/retriable.rb:48:in `retriable'
/home/mauricio/projects/ruby/spi-test/lib/spitest/webapp.rb:15:in `upload'
/home/mauricio/projects/ruby/spi-test/lib/spitest/launcher.rb:44:in `block (3 levels) in upload_to_all_dests'
/home/mauricio/projects/ruby/spi-test/lib/spitest/thread_pool.rb:21:in `call'
/home/mauricio/projects/ruby/spi-test/lib/spitest/thread_pool.rb:21:in `block (2 levels) in start'
I have already changed the TCP buffers but this is still causing issues when uploading lots of files.
Any idea how to fix this?
I'm running Ubuntu 14.04 and Ruby 2.2.0p0.

Issue in using Twitter API from Ruby

I am new bee to twitter API and MongoDb. I am trying out a ruby example from the book 'MongoDb In Action', Chapter-3 which connects to Twitter and gets feeds based on given tags. I have done the ruby set up as suggested. I am getting the following exception, which I think is related to ruby set up. Any hint is highly appreciated.
/usr/lib/ruby/1.9.1/net/http.rb:762:in `initialize': execution expired (Twitter::Error::ClientError)
from /usr/lib/ruby/1.9.1/net/http.rb:762:in `open'
from /usr/lib/ruby/1.9.1/net/http.rb:762:in `block in connect'
from /usr/lib/ruby/1.9.1/net/http.rb:762:in `connect'
from /usr/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
from /usr/lib/ruby/1.9.1/net/http.rb:744:in `start'
from /usr/lib/ruby/1.9.1/net/http.rb:1284:in `request'
from /var/lib/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/adapter/net_http.rb:75:in `perform_request'
from /var/lib/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/adapter/net_http.rb:38:in `call'
from /var/lib/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/response.rb:8:in `call'
from /var/lib/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/response.rb:8:in `call'
from /var/lib/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/response.rb:8:in `call'
from /var/lib/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/request/url_encoded.rb:14:in `call'
from /var/lib/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/request/multipart.rb:13:in `call'
from /var/lib/gems/1.9.1/gems/twitter-4.8.1/lib/twitter/request/multipart_with_file.rb:14:in `call'
from /var/lib/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/connection.rb:247:in `run_request'
from /var/lib/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/connection.rb:112:in `post'
from /var/lib/gems/1.9.1/gems/twitter-4.8.1/lib/twitter/client.rb:108:in `request'
from /var/lib/gems/1.9.1/gems/twitter-4.8.1/lib/twitter/client.rb:72:in `post'
from /var/lib/gems/1.9.1/gems/twitter-4.8.1/lib/twitter/api/utils.rb:82:in `object_from_response'
from /var/lib/gems/1.9.1/gems/twitter-4.8.1/lib/twitter/api/oauth.rb:24:in `token'
from /var/lib/gems/1.9.1/gems/twitter-4.8.1/lib/twitter/client.rb:96:in `block in request_setup'
from /var/lib/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/connection.rb:102:in `block in get'
from /var/lib/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/connection.rb:243:in `block in run_request'
from /var/lib/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/connection.rb:258:in `block in build_request'
from /var/lib/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/request.rb:35:in `block in create'
from /var/lib/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/request.rb:34:in `tap'
from /var/lib/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/request.rb:34:in `create'
from /var/lib/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/connection.rb:254:in `build_request'
from /var/lib/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/connection.rb:239:in `run_request'
from /var/lib/gems/1.9.1/gems/faraday-0.8.7/lib/faraday/connection.rb:100:in `get'
from /var/lib/gems/1.9.1/gems/twitter-4.8.1/lib/twitter/client.rb:108:in `request'
from /var/lib/gems/1.9.1/gems/twitter-4.8.1/lib/twitter/client.rb:66:in `get'
from /var/lib/gems/1.9.1/gems/twitter-4.8.1/lib/twitter/api/utils.rb:82:in `object_from_response'
from /var/lib/gems/1.9.1/gems/twitter-4.8.1/lib/twitter/api/search.rb:32:in `search'
from /var/lib/gems/1.9.1/gems/twitter-4.8.1/lib/twitter.rb:60:in `method_missing'
from /home/hadoop/archiver.rb:27:in `save_tweets_for'
from /home/hadoop/archiver.rb:21:in `update'
from update.rb:5:in `block in <main>'
from update.rb:3:in `each'
from update.rb:3:in `<main>'
The book you are reading was printed in 2011 and appears to use APIv1 which has recently been depreciated by twitter.
https://dev.twitter.com/docs/faq#17750
You'll need to set up oauth and I suggest you start with the twitter gem documentation.
https://github.com/sferik/twitter

Getting error "getaddrinfo: No such host is known. (Socke tError)" with mechanize gem

I tried the below code:
require 'mechanize'
agent = Mechanize.new{|a| a.ssl_version, a.verify_mode = 'SSLv3', OpenSSL::SSL::VERIFY_NONE}
page = agent.get "https://gegsltraining.aravo.com/"
page=page.link_with(:dom_class => "button").click()
But my bad getting the below error.
D:\WIPData\Ruby\Scripts>mechanize_dowload.rb
C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net/http/persist
ent/ssl_reuse.rb:29:in `initialize': getaddrinfo: No such host is known. (Socke
tError)
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net
/http/persistent/ssl_reuse.rb:29:in `open'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net
/http/persistent/ssl_reuse.rb:29:in `block in connect'
from C:/Ruby193/lib/ruby/1.9.1/timeout.rb:54:in `timeout'
from C:/Ruby193/lib/ruby/1.9.1/timeout.rb:99:in `timeout'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net
/http/persistent/ssl_reuse.rb:29:in `connect'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:755:in `do_start'
from C:/Ruby193/lib/ruby/1.9.1/net/http.rb:750:in `start'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net
/http/persistent.rb:628:in `start'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net
/http/persistent.rb:570:in `connection_for'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/net-http-persistent-2.8/lib/net
/http/persistent.rb:926:in `request'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/mechanize-2.5.1/lib/mechanize/h
ttp/agent.rb:258:in `fetch'
from C:/Ruby193/lib/ruby/gems/1.9.1/gems/mechanize-2.5.1/lib/mechanize.r
b:407:in `get'
from D:/WIPData/Ruby/Scripts/mechanize_dowload.rb:5:in `<main>'
D:\WIPData\Ruby\Scripts>
The same script ran perfectly on my personal machine,but not in my company.
Could you please me to fix the same?
Thanks in advance
That error means dns is not resolving. In my experience it's usually because your internet is down.

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