To connect a CockrachDB Serverless, I have to pass some parameters in the connection string (?sslmode=verify-full&options=--cluster%3Dblackstack-4545).
The full connection string looks like this:
postgresql://blackstack:<db-password>#free-tier14.aws-us-east-1.cockroachlabs.cloud:26257/blackstack?sslmode=verify-full&options=--cluster%3Dblackstack-4545
From Ruby, such a connection string works fine if I use the pg gem, but it fails if I use Sequel.
Here is the testing code:
require 'pg'
require 'sequel'
DATABASE_URL="postgresql://blackstack:<db-password>#free-tier14.aws-us-east-1.cockroachlabs.cloud:26257/blackstack?sslmode=verify-full&options=--cluster%3Dblackstack-4545"
conn = PG.connect(DATABASE_URL)
p conn.exec("SELECT 'Hello CockroachDB!' AS message").first
# => {"message"=>"Hello CockroachDB!"}
DB = Sequel.connect(DATABASE_URL)
p DB["SELECT 'Hello CockroachDB!' AS message"].first
# => "/home/leandro/.rvm/gems/ruby-3.1.2/gems/pg-1.3.5/lib/pg/connection.rb:637:in `async_connect_or_reset': PG::ConnectionBad: FATAL: codeParamsRoutingFailed: missing cluster identifier (Sequel::DatabaseConnectionError)"
Here is the full output of the command:
leandro#dev5:~/code/mysaas/examples/1.db$ ruby 1.connect.rb
{"message"=>"Hello CockroachDB!"}
/home/leandro/.rvm/gems/ruby-3.1.2/gems/pg-1.3.5/lib/pg/connection.rb:637:in `async_connect_or_reset': PG::ConnectionBad: FATAL: codeParamsRoutingFailed: missing cluster identifier (Sequel::DatabaseConnectionError)
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/pg-1.3.5/lib/pg/connection.rb:707:in `new'
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/sequel-5.56.0/lib/sequel/adapters/postgres.rb:208:in `connect'
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/sequel-5.56.0/lib/sequel/connection_pool.rb:122:in `make_new'
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/sequel-5.56.0/lib/sequel/connection_pool/threaded.rb:209:in `assign_connection'
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/sequel-5.56.0/lib/sequel/connection_pool/threaded.rb:139:in `acquire'
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/sequel-5.56.0/lib/sequel/connection_pool/threaded.rb:91:in `hold'
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/sequel-5.56.0/lib/sequel/database/connecting.rb:269:in `synchronize'
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/sequel-5.56.0/lib/sequel/database/connecting.rb:278:in `test_connection'
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/sequel-5.56.0/lib/sequel/database/misc.rb:175:in `initialize'
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/sequel-5.56.0/lib/sequel/database/connecting.rb:57:in `new'
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/sequel-5.56.0/lib/sequel/database/connecting.rb:57:in `connect'
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/sequel-5.56.0/lib/sequel/core.rb:124:in `connect'
from 1.connect.rb:10:in `<main>'
/home/leandro/.rvm/gems/ruby-3.1.2/gems/pg-1.3.5/lib/pg/connection.rb:637:in `async_connect_or_reset': FATAL: codeParamsRoutingFailed: missing cluster identifier (PG::ConnectionBad)
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/pg-1.3.5/lib/pg/connection.rb:707:in `new'
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/sequel-5.56.0/lib/sequel/adapters/postgres.rb:208:in `connect'
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/sequel-5.56.0/lib/sequel/connection_pool.rb:122:in `make_new'
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/sequel-5.56.0/lib/sequel/connection_pool/threaded.rb:209:in `assign_connection'
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/sequel-5.56.0/lib/sequel/connection_pool/threaded.rb:139:in `acquire'
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/sequel-5.56.0/lib/sequel/connection_pool/threaded.rb:91:in `hold'
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/sequel-5.56.0/lib/sequel/database/connecting.rb:269:in `synchronize'
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/sequel-5.56.0/lib/sequel/database/connecting.rb:278:in `test_connection'
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/sequel-5.56.0/lib/sequel/database/misc.rb:175:in `initialize'
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/sequel-5.56.0/lib/sequel/database/connecting.rb:57:in `new'
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/sequel-5.56.0/lib/sequel/database/connecting.rb:57:in `connect'
from /home/leandro/.rvm/gems/ruby-3.1.2/gems/sequel-5.56.0/lib/sequel/core.rb:124:in `connect'
from 1.connect.rb:10:in `<main>'
I fixed it my self.
I worked with the below connection string using the format cluster_name.db_name instead.
postgresql://blackstack:<db-password>#free-tier14.aws-us-east-1.cockroachlabs.cloud:26257/blackstack-4545.blackstack?sslmode=verify-full
Related
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
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 :-)
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.
I am trying to connect to FTPS server with Ruby gem double_bag_ftps using following code.
require 'double_bag_ftps'
ftps = DoubleBagFTPS.new
ftps.ssl_context = DoubleBagFTPS.create_ssl_context(:verify_mode => OpenSSL::SSL::VERIFY_NONE)
ftps.connect('xx.xx.xx.xx')
ftps.login('user', 'password')
files = ftps.nlst
puts files.length
I get the below error when trying to connect.
/home/indika/.rvm/gems/ruby-1.9.3-p0#global/gems/double-bag-ftps-0.1.0/lib/double_bag_ftps.rb:148:in `connect': Broken pipe - SSL_connect (Errno::EPIPE)
from /home/msc22/.rvm/gems/ruby-1.9.3-p0#global/gems/double-bag-ftps-0.1.0/lib/double_bag_ftps.rb:148:in `ssl_socket'
from /home/msc22/.rvm/gems/ruby-1.9.3-p0#global/gems/double-bag-ftps-0.1.0/lib/double_bag_ftps.rb:125:in `transfercmd'
from /home/msc22/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/ftp.rb:478:in `block (2 levels) in retrlines'
from /home/msc22/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/ftp.rb:178:in `with_binary'
from /home/msc22/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/ftp.rb:477:in `block in retrlines'
from /home/msc22/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
from /home/msc22/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/ftp.rb:476:in `retrlines'
from /home/msc22/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/ftp.rb:703:in `nlst'
from backup_collector.rb:8:in `<main>'
Any help on this is greatly appreciated.
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