I have been looking into the RubyWMQ gem trying to connect to a Websphere queue, but am having no luck. My ultimate goal is to connect to, read and put messages to the queue using Ruby. I have used the gem authors documentation and examples here with no luck as well. currently I have tried this:
queue = WMQ::QueueManager.connect(
:q_mgr_name => 'MYQUEUEMANAGERNAMEHERE',
:exception_on_error => true,
:trace_level => 2,
# :connect_options => WMQ::MQCNO_FASTBATH_BINDING, # this errors
:channel_name => 'MYQUEUEMANAGERNAMEHERE',
:connection_name => 'localhost(1414)',
:transport_type => WMQ::MQXPT_TCP,
:user_identifier => 'MYUSERNAMEHERE',
:password => 'MYPASSWORDHERE')
I believe the first error I am receiving has to do with the Webshpere MQ client itself, or the install of the gem. i installed RubyWMQ using this command:
gem install rubywmq --platform=ruby -- '--with-mqm-include="C:\Program Files\IBM\WebSphereMQ\tools\c\include"'
I am using IBM WebSphere MQ version 7.1.0.3, located in C:\Program Files\IBM\WebSphere MQ...
I get this error when running my code:
WMQ::QueueManager#connect(). Failed to load MQ Library:mqic32, rc=126 (WMQ::WMQException)
I can see the "mqic32.dll" file in C:\Program Files\IBM\WebSphere MQ\bin, so I am not sure exactly what the gem code is doing..
Managed to fix this by adding C:\Program Files\IBM\WebSphere MQ\bin64 to my user $Path.
Which was odd, because bin and bin64 had both been added to the System $path variable by the IBM install.
(This is with a mingw ruby install)
Related
I have a ruby script that uses the net::ssh gem.
Its a simple script to tunnel through a jump-off server to a destination box. The box is only visible to the jump-off server. Here is the script:
require 'net/ssh/proxy/command'
require "net/ssh"
class TestTunnel
def initialize
proxy = Net::SSH::Proxy::Command.new('ssh admin#10.10.10.10 nc %h %p 2>/dev/null')
p "proxy gotten"
Net::SSH.start("host1", "admin", :password => "admin", :proxy => proxy) do |ssh|
hostname = ssh.exec!("hostname")
p "In #{hostname}"
end
end
end
b=TestTunnel.new
The issue is the script runs in ruby but not in jruby. My framework runs off jruby so I need to use it with jruby.
My solution was to call a bash script from my jruby script to setup the tunnel and run commands there but I would rather have everything done within jruby.
Here are the errors I get:
~/src/main/ruby$ jruby --1.9 scripts/test_tunnel.rb
"proxy gotten"
IO::EAGAINWaitReadable: Resource temporarily unavailable - errno backtraces disabled; run with -Xerrno.backtrace=true to enable
And when I run in ruby:
~/src/main/ruby$ ruby scripts/test_tunnel.rb
"proxy gotten"
"In vz-int-api02\n"
~/src/main/ruby$
When I run with -Xerrno.backtrace=true I can see that jruby is 1.7.9 and I can see that its using ruby 1.9:
~/src/main/ruby$ jruby -Xerrno.backtrace=true --1.9 scripts/test_tunnel.rb
"proxy gotten"
IO::EAGAINWaitReadable: Resource temporarily unavailable -
read_nonblock at org/jruby/RubyIO.java:2856
recv at /usr/local/jruby-1.7.9/lib/ruby/gems/shared/gems/net-ssh-2.9.2/lib/net/ssh/proxy/command.rb:75
fill at /usr/local/jruby-1.7.9/lib/ruby/gems/shared/gems/net-ssh-2.9.2/lib/net/ssh/buffered_io.rb:65
next_packet at /usr/local/jruby-1.7.9/lib/ruby/gems/shared/gems/net-ssh-2.9.2/lib/net/ssh/transport/packet_stream.rb:88
poll_message at /usr/local/jruby-1.7.9/lib/ruby/gems/shared/gems/net-ssh-2.9.2/lib/net/ssh/transport/session.rb:183
loop at org/jruby/RubyKernel.java:1519
poll_message at /usr/local/jruby-1.7.9/lib/ruby/gems/shared/gems/net-ssh-2.9.2/lib/net/ssh/transport/session.rb:178
wait at /usr/local/jruby-1.7.9/lib/ruby/gems/shared/gems/net-ssh-2.9.2/lib/net/ssh/transport/session.rb:215
loop at org/jruby/RubyKernel.java:1519
wait at /usr/local/jruby-1.7.9/lib/ruby/gems/shared/gems/net-ssh-2.9.2/lib/net/ssh/transport/session.rb:213
initialize at /usr/local/jruby-1.7.9/lib/ruby/gems/shared/gems/net-ssh-2.9.2/lib/net/ssh/transport/session.rb:87
start at /usr/local/jruby-1.7.9/lib/ruby/gems/shared/gems/net-ssh-2.9.2/lib/net/ssh.rb:207
initialize at scripts/test_tunnel.rb:8
(root) at scripts/test_tunnel.rb:15
~/src/main/ruby$ jruby -Xerrno.backtrace=true --1.9 --version
jruby 1.7.9 (1.9.3p392) 2013-12-06 87b108a on Java HotSpot(TM) 64-Bit Server VM 1.8.0_72-b15 +indy [linux-amd64]
~/src/main/ruby$
Is there any way to get this to run in jruby like it does in ruby or is my solution to call a bash script from within jruby the only way to do this?
A
This sounds a lot like this bug in net-ssh that was fixed in net-ssh 3.0.2.
The commit message that closed that issue t was "Bugfix: proxy command was using nonblocking io api incorrectly causing rare IO::EAGAIN errors" which sounds like exactly what you are getting.
I've searched in the archive but could not find an answer to my dilemma. I'm coding in Ruby and using watir webdriver framework on my local Mac Yosemite and want to connect to postgres database on a linux box.
I have the required ruby gems installed on my local Mac
* LOCAL GEMS *
dbd-pg (0.3.9)
pg (0.18.4)
dbi (0.4.5, 0.4.4)
I am using the following code.
require 'rubygems'
require 'pg'
require 'dbd/pg'
require 'dbi'
conn = PGconn.connect("10.0.xx.xx","5432",'','',"mydbname","dbuser", "")
res = conn.exec('select * from priorities_map;')
puts res.getvalue(0,0)
conn.close if conn
On running this
I a getting these errors
.initialize': Could not connect to server: Connection refused (PG::ConnectionBad)
Is the server running on host "10.0.xx.xx" and accepting
TCP/IP connections on port 5432?
If I use the code
dbh = DBI.connect("dbi:pg:mydbname:ipaddress", "user", "")
row = dbh.exec('select * from etr_priorities_map;')
puts row.getvalue(0,0)
dbh.disconnect if dbh
I get the error
block in load_driver': Unable to load driver 'pg' (underlying error: wrong constant name pg) (DBI::InterfaceError) from System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
I am new to Ruby. How can I resolve these issues?
The first error, as #Doon said in the comments, comes from the TCP connection and usually means your database is not listening on the network. Most PostgreSQL packages come with a default configuration that only allows local connections, but you can enable connections over the network in the server configuration via the listen_addresses setting. I installed PostgreSQL through Homebrew on my Mac, and my config is at /usr/local/var/postgres/postgresql.conf, but if you installed it some other way the path may be different.
The second error is happening because the "driver" part of the connection string is case-sensitive, and the DBD driver for Postgres is named Pg, not pg. Try this:
dbh = DBI.connect("dbi:Pg:mydbname:ipaddress", "user", "")
Also, unless you have your heart set on using Ruby/DBI, you might want to consider using a more-recently maintained library. Ruby-DBI is very well-written and tested, but it hasn't seen a release since 2010, and Ruby itself has changed pretty significantly in the interim.
If you do want to consider alternatives, I use Sequel for mostly everything, and I highly recommend it, especially for Postgres development, but both DataMapper and ActiveRecord have a large userbase as well.
Has anyone installed tomcat and jdk7 packages on windows server 2008 using puppet.
puppet master is (Ubuntu)
puppet agent is (windows server 2008)
node 'puppetwindows' {
package {'jdk7 v7.0.79.1':
ensure => present,
source => 'puppet:///modules/jdk//jdk-7u79-windows-x64.exe',
path => “C:\jdk-7u79-windows-x64.exe”
install_options => ['/VERYSILENT'],
below is the output;
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Could
not parse for environment production: invalid byte sequence in US-ASCII at /etc
/puppet/manifests/site.pp:1 on node puppetwindows.pramati.com
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run
Your file is using UTF-8 with BOM. Convert it to UTF-8 w/out BOM.
You should also use puppet parser validate path\to\manifest.pp so you can get an idea of whether the file contains good Puppet code and as a byproduct whether Puppet can read the file (are the encodings usable?).
I just restarted the puppet master and it worked fine.
installed chocolatey(package manager for windows same as apt-get on Ubuntu) on both Ubuntu(puppet master) windows(puppet agent)
and with the below code I was able to install tomcat successfully.
node 'puppetwindows.XXXX.com' {
package { 'tomcat':
provider => 'chocolatey',
ensure => 'latest',
}
}
I am having some problems trying to bootstrap a windows node for Chef. This node was initially able to be partially bootstrapped, it was getting through most of the process but however, failing near the end - on the windows client itself I can see a number of expected files under C:\Chef
However since upgrading my Ruby and Knife-Windows to remedy the original issue - I am now not able to bootstrap at all, I get the error below:
chefadmin#AUK-CHEFMGT1:~$ knife bootstrap windows winrm 10.28.154.61 -x chefadmin -P xxxxxx
/opt/chefdk/embedded/lib/ruby/gems/2.1.0/gems/chef-12.5.1/lib/chef/mixin/path_sanity.rb:25:
warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777
Waiting for remote response before bootstrap.10.28.154.61 .
10.28.154.61 Response received.
Remote node responded after 0.01 minutes.
Bootstrapping Chef on 10.28.154.61
ERROR: RuntimeError: Knife-Windows < 1.0 does not support validatorless bootstraps
I've tried a few different versions of knife-windows, initially 1.1.1, and most recently the pre-release version of 1.0.0 rc1, however, they are all giving me this error.
I am not sure why this is a problem, as the validation.pem does exist on the windows client in C:\Chef\
In case it matters, here is my knife.rb config file:
chefadmin#AUK-CHEFMGT1:~$
GNU nano 2.2.6 File: /home/chefadmin/chef-repo/.chef/knife.rb
current_dir = File.dirname(__FILE__)
log_level :info
log_location STDOUT
node_name "chefadmin"
client_key "#{current_dir}/ChefRSA.pem"
validation_client_name "company"
validation_key "#{current_dir}/companyvalidator"
chef_server_url "https://10.28.253.101/organizations/company"
syntax_check_cache_path "#{ENV['HOME']}/.chef/syntaxcache"
cookbook_path ["#{current_dir}/../cookbooks"]
"#{current_dir}/companyvalidator" Does that file exist? Usually that would be something ending in .pem. If that path isn't a thing, it would fall back to new-style bootstrapping which I don't think works on Windows yet.
I have installed predictionio through brew on my osx ( Maverick ) and i can start the admin's service (http://0.0.0.0:9000 ) and the api's server (http://0.0.0.0:8000).
But reading the docs, with the ruby's sdk, says:
# Create a client object.
client = PredictionIO::EventClient.new(<ACCESS KEY>, <URL OF EVENTSERVER>)
At first, i have inserted the api's url, but reading other docs ( like the python's sdk ) says that the eventserver runs on http://0.0.0.0:7070.
If i try to create a event:
client.create_event('rate', 'user', rate.user_id, { 'targetEntityType'=> 'item', 'targetEntityId' => rate.rateable_id, 'properties'=> {'rating'=> 3 }})
it always return the same response: 'PredictionIO::EventClient::NotCreatedError: Your request is not supported'
The guide says that the command to run this server is:
pio eventserver
But I don't have this bin. I start everything with the script 'predicitonio-start-all.sh' but with this I can't start this event server.
Thanks in advance !!
The Homebrew script is maintained by community and has not yet been updated to 0.8.4 yet. It is using 0.7.3 (http://braumeister.org/formula/predictionio) which does not work with the current documentation.
Please follow the instructions here to install the latest version: http://docs.prediction.io/install/