Upgrading ES and logstash - elasticsearch

I am new to Logstash and ES, and I have to update Logstash and ES for my company. I downloaded the newest version and I get this error.
{:timestamp=>"2018-05-07T14:08:55.874000-0400", :message=>"Attempted to send a bulk request to Elasticsearch configured at '[\"http://localhost:9400\"]',
but an error occurred and it failed! Are you sure you can reach elasticsearch from this machine using the configuration provided?",
:error_message=>"[406] {\"error\":\"Content-Type header [text/plain; charset=ISO-8859-1] is not supported\",\"status\":406}",
:error_class=>"Elasticsearch::Transport::Transport::Errors::NotAcceptable",
:backtrace=>["C:/cmoc/bin/logstash/2.3.4/vendor/bundle/jruby/1.9/gems/elasticsearch-transport-1.0.18/lib/elasticsearch/transport/transport/base.rb:201:in `__raise_transport_error'",
"C:/cmoc/bin/logstash/2.3.4/vendor/bundle/jruby/1.9/gems/elasticsearch-transport-1.0.18/lib/elasticsearch/transport/transport/base.rb:312:in `perform_request'",
"C:/cmoc/bin/logstash/2.3.4/vendor/bundle/jruby/1.9/gems/elasticsearch-transport-1.0.18/lib/elasticsearch/transport/transport/http/manticore.rb:67:in `perform_request'",
"C:/cmoc/bin/logstash/2.3.4/vendor/bundle/jruby/1.9/gems/elasticsearch-transport-1.0.18/lib/elasticsearch/transport/client.rb:128:in `perform_request'",
"C:/cmoc/bin/logstash/2.3.4/vendor/bundle/jruby/1.9/gems/elasticsearch-api-1.0.18/lib/elasticsearch/api/actions/bulk.rb:90:in `bulk'",
"C:/cmoc/bin/logstash/2.3.4/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-2.7.1-java/lib/logstash/outputs/elasticsearch/http_client.rb:53:in `non_threadsafe_bulk'",
"C:/cmoc/bin/logstash/2.3.4/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-2.7.1-java/lib/logstash/outputs/elasticsearch/http_client.rb:38:in `bulk'",
"org/jruby/ext/thread/Mutex.java:149:in `synchronize'",
"C:/cmoc/bin/logstash/2.3.4/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-2.7.1-java/lib/logstash/outputs/elasticsearch/http_client.rb:38:in `bulk'",
"C:/cmoc/bin/logstash/2.3.4/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-2.7.1-java/lib/logstash/outputs/elasticsearch/common.rb:172:in `safe_bulk'",
"C:/cmoc/bin/logstash/2.3.4/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-2.7.1-java/lib/logstash/outputs/elasticsearch/common.rb:101:in `submit'",
"C:/cmoc/bin/logstash/2.3.4/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-2.7.1-java/lib/logstash/outputs/elasticsearch/common.rb:86:in `retrying_submit'",
"C:/cmoc/bin/logstash/2.3.4/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-2.7.1-java/lib/logstash/outputs/elasticsearch/common.rb:29:in `multi_receive'",
"org/jruby/RubyArray.java:1653:in `each_slice'",
"C:/cmoc/bin/logstash/2.3.4/vendor/bundle/jruby/1.9/gems/logstash-output-elasticsearch-2.7.1-java/lib/logstash/outputs/elasticsearch/common.rb:28:in `multi_receive'",
"C:/cmoc/bin/logstash/2.3.4/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.4-java/lib/logstash/output_delegator.rb:130:in `worker_multi_receive'",
"C:/cmoc/bin/logstash/2.3.4/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.4-java/lib/logstash/output_delegator.rb:114:in `multi_receive'",
"C:/cmoc/bin/logstash/2.3.4/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.4-java/lib/logstash/pipeline.rb:301:in `output_batch'", "org/jruby/RubyHash.java:1342:in `each'",
"C:/cmoc/bin/logstash/2.3.4/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.4-java/lib/logstash/pipeline.rb:301:in `output_batch'",
"C:/cmoc/bin/logstash/2.3.4/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.4-java/lib/logstash/pipeline.rb:232:in `worker_loop'",
"C:/cmoc/bin/logstash/2.3.4/vendor/bundle/jruby/1.9/gems/logstash-core-2.3.4-java/lib/logstash/pipeline.rb:201:in `start_workers'"], :level=>:error}

The problem in my case was that I had a mismatch version of Logstash(LS) and Elastisearch(ES). So if you have the same problem or something similar, you should try putting them both at the same version.

Related

Logstash getting syntax errors after upgrading to 7.13.3

So my company has me upgrading our Logstash version for our repository to 7.13.3 from 6.6.2.
After fixing some of the other errors with the upgrade, it seems the last piece is to change the ruby syntax in the config file.
However, I am not too familiar with the language and not sure why the syntax no longer works.
Here is an example of one of the syntax errors we get from the file.
[2021-07-21T16:10:22,524][ERROR][logstash.javapipeline ][main] Pipeline error {
:pipeline_id=>"main",
:exception=>#<RegexpError: unmatched range specifier in char-class: /(?<ucd_environment_name1>(?<=release_ucd_environment_name:)[\w-.]*)/m>,
:backtrace=>[
"org/jruby/RubyRegexp.java:965:in `initialize'",
"/Users/808451090/Desktop/app/logstash-7.13.3/vendor/bundle/jruby/2.5.0/gems/jls-grok-0.11.5/lib/grok-pure.rb:127:in `compile'",
"/Users/808451090/Desktop/app/logstash-7.13.3/vendor/bundle/jruby/2.5.0/gems/logstash-filter-grok-4.4.0/lib/logstash/filters/grok.rb:282:in `block in register'",
"org/jruby/RubyArray.java:1809:in `each'",
"/Users/808451090/Desktop/app/logstash-7.13.3/vendor/bundle/jruby/2.5.0/gems/logstash-filter-grok-4.4.0/lib/logstash/filters/grok.rb:276:in `block in register'",
"org/jruby/RubyHash.java:1415:in `each'",
"/Users/808451090/Desktop/app/logstash-7.13.3/vendor/bundle/jruby/2.5.0/gems/logstash-filter-grok-4.4.0/lib/logstash/filters/grok.rb:271:in `register'",
"org/logstash/config/ir/compiler/AbstractFilterDelegatorExt.java:75:in `register'",
"/Users/808451090/Desktop/app/logstash-7.13.3/logstash-core/lib/logstash/java_pipeline.rb:228:in `block in register_plugins'",
"org/jruby/RubyArray.java:1809:in `each'",
"/Users/808451090/Desktop/app/logstash-7.13.3/logstash-core/lib/logstash/java_pipeline.rb:227:in `register_plugins'",
"/Users/808451090/Desktop/app/logstash-7.13.3/logstash-core/lib/logstash/java_pipeline.rb:586:in `maybe_setup_out_plugins'",
"/Users/808451090/Desktop/app/logstash-7.13.3/logstash-core/lib/logstash/java_pipeline.rb:240:in `start_workers'",
"/Users/808451090/Desktop/app/logstash-7.13.3/logstash-core/lib/logstash/java_pipeline.rb:185:in `run'",
"/Users/808451090/Desktop/app/logstash-7.13.3/logstash-core/lib/logstash/java_pipeline.rb:137:in `block in start'"
],
"pipeline.sources"=>["/Users/808451090/Desktop/app/logstash-7.13.3/devops-jenkins/jenkins.conf"],
:thread=>"#<Thread:0x4fbac51b run>"
}
The line this error references:
grok {
match => { "message_string" => "(?<ucd_environment_name1>(?<=release_ucd_environment_name:)[\w-.]*)" }
}
There are other lines where this error occurs, but they all have similar syntax to this line so I'm sure I can apply the same change to those ones too.
If anyone can point me to how I can change this line to check for the same expression that this Logstash version accepts syntactically.
The error is
unmatched range specifier in char-class
In character definitions, you can define ranges of characters as e.g. [a-z]. When using a literal dash character there, you have to be careful to either escape it or to make sure it unambiguously defines a single character rather than a range.
In your example, you can just escape the dash in your regex to make sure the dash is regarded as a single possible character:
grok {
match => { "message_string" => "(?<ucd_environment_name1>(?<=release_ucd_environment_name:)[\w\-.]*)" }
}

Logstash: :message=>"Failed to flush outgoing items"

I have set up a 3 node ES instance (elasticsearch-1.4.2). It works properly when the logstash is run from 2 nodes. However an exception as shown below is thrown on running the logstash on 3rd node. Could you please help?
{:timestamp=>"2015-11-30T06:50:58.873000-0700",
:message=>"Failed to flush outgoing items",
:outgoing_count=>1,
:exception=>#<Errno::EBADF: Bad file descriptor - Bad file descriptor>,
:backtrace=>[
"org/jruby/RubyIO.java:2097:in `close'",
"//scratch/LOGSTASH/logstash-1.4.2/vendor/bundle/jruby/1.9/gems/ftw-0.0.39/lib/ftw/connection.rb:173:in `connect'",
"org/jruby/RubyArray.java:1613:in `each'",
"//scratch/LOGSTASH/logstash-1.4.2/vendor/bundle/jruby/1.9/gems/ftw-0.0.39/lib/ftw/connection.rb:139:in `connect'",
"//scratch/LOGSTASH/logstash-1.4.2/vendor/bundle/jruby/1.9/gems/ftw-0.0.39/lib/ftw/agent.rb:406:in `connect'",
"org/jruby/RubyProc.java:271:in `call'",
"//scratch/LOGSTASH/logstash-1.4.2/vendor/bundle/jruby/1.9/gems/ftw-0.0.39/lib/ftw/pool.rb:48:in `fetch'",
"//scratch/LOGSTASH/logstash-1.4.2/vendor/bundle/jruby/1.9/gems/ftw-0.0.39/lib/ftw/agent.rb:403:in `connect'",
"//scratch/LOGSTASH/logstash-1.4.2/vendor/bundle/jruby/1.9/gems/ftw-0.0.39/lib/ftw/agent.rb:319:in `execute'",
"//scratch/LOGSTASH/logstash-1.4.2/vendor/bundle/jruby/1.9/gems/ftw-0.0.39/lib/ftw/agent.rb:217:in `post!'",
"//scratch/LOGSTASH/logstash-1.4.2/lib/logstash/outputs/elasticsearch/protocol.rb:106:in `bulk_ftw'",
"//scratch/LOGSTASH/logstash-1.4.2/lib/logstash/outputs/elasticsearch/protocol.rb:80:in `bulk'",
"//scratch/LOGSTASH/logstash-1.4.2/lib/logstash/outputs/elasticsearch.rb:315:in `flush'",
"//scratch/LOGSTASH/logstash-1.4.2/vendor/bundle/jruby/1.9/gems/stud-0.0.17/lib/stud/buffer.rb:219:in `buffer_flush'",
"org/jruby/RubyHash.java:1339:in `each'",
"//scratch/LOGSTASH/logstash-1.4.2/vendor/bundle/jruby/1.9/gems/stud-0.0.17/lib/stud/buffer.rb:216:in `buffer_flush'",
"//scratch/LOGSTASH/logstash-1.4.2/vendor/bundle/jruby/1.9/gems/stud-0.0.17/lib/stud/buffer.rb:193:in `buffer_flush'",
"//scratch/LOGSTASH/logstash-1.4.2/vendor/bundle/jruby/1.9/gems/stud-0.0.17/lib/stud/buffer.rb:159:in `buffer_receive'",
"//scratch/LOGSTASH/logstash-1.4.2/lib/logstash/outputs/elasticsearch.rb:311:in `receive'",
"//scratch/LOGSTASH/logstash-1.4.2/lib/logstash/outputs/base.rb:86:in `handle'",
"(eval):148:in `initialize'",
"org/jruby/RubyProc.java:271:in `call'",
"//scratch/LOGSTASH/logstash-1.4.2/lib/logstash/pipeline.rb:266:in `output'",
"//scratch/LOGSTASH/logstash-1.4.2/lib/logstash/pipeline.rb:225:in `outputworker'",
"//scratch/LOGSTASH/logstash-1.4.2/lib/logstash/pipeline.rb:152:in `start_outputs'"],
:level=>:warn}
I could solve this by passing the max open file parameter in the command line while starting ES as >>
bin/elasticsearch -Des.max-open-files=true -f

Unable to insert json arrays from Logstash to mongoDB

I'm using Logstash 1.5.2
trying to insert datas in MongoDB with logstash-output-mongodb
It works well only when my parsed logs doesn't contain arrays, when the JSON contains array it generates an exception.
Failed to send event to MongoDB
undefined methodbson_type
NoMethodError: undefined method `error_code' for #NoMethodError:0x39794292
#cancelled=false>, :exception=>#<NoMethodError: undefined methodbson_type' for "2015-08-24T12:26:19.664Z":LogStash::Timestamp>, :backtrace=>["/opt/logstash/vendor/bundle/jruby/1.9/gems/bson-3.2.1-java/lib/bson/hash.rb:44:in to_bson'", "org/jruby/RubyHash.java:1341:ineach'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/bson-3.2.1-java/lib/bson/hash.rb:43:in to_bson'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/bson-3.2.1-java/lib/bson/encodable.rb:57:inencode_with_placeholder_and_null'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/bson-3.2.1-java/lib/bson/hash.rb:42:in to_bson'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/bson-3.2.1-java/lib/bson/array.rb:49:into_bson'", "org/jruby/RubyArray.java:1613:in each'", "org/jruby/RubyEnumerable.java:978:ineach_with_index'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/bson-3.2.1-java/lib/bson/array.rb:46:in to_bson'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/bson-3.2.1-java/lib/bson/encodable.rb:57:inencode_with_placeholder_and_null'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/bson-3.2.1-java/lib/bson/array.rb:45:in to_bson'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/bson-3.2.1-java/lib/bson/hash.rb:46:into_bson'", "org/jruby/RubyHash.java:1341:in each'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/bson-3.2.1-java/lib/bson/hash.rb:43:into_bson'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/bson-3.2.1-java/lib/bson/encodable.rb:57:in encode_with_placeholder_and_null'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/bson-3.2.1-java/lib/bson/hash.rb:42:into_bson'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/mongo-2.0.6/lib/mongo/protocol/serializers.rb:155:in serialize'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/mongo-2.0.6/lib/mongo/protocol/message.rb:153:inserialize_fields'", "org/jruby/RubyArray.java:1613:in each'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/mongo-2.0.6/lib/mongo/protocol/message.rb:141:inserialize_fields'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/mongo-2.0.6/lib/mongo/protocol/message.rb:70:in serialize'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/mongo-2.0.6/lib/mongo/server/connection.rb:123:inwrite'", "org/jruby/RubyArray.java:1613:in each'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/mongo-2.0.6/lib/mongo/server/connection.rb:122:inwrite'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/mongo-2.0.6/lib/mongo/server/connectable.rb:66:in dispatch'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/mongo-2.0.6/lib/mongo/loggable.rb:44:inlog'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/mongo-2.0.6/lib/mongo/loggable.rb:67:in log_debug'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/mongo-2.0.6/lib/mongo/server/connectable.rb:65:indispatch'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/mongo-2.0.6/lib/mongo/operation/executable.rb:35:in execute'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/mongo-2.0.6/lib/mongo/server/connection_pool.rb:99:inwith_connection'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/mongo-2.0.6/lib/mongo/server/context.rb:63:in with_connection'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/mongo-2.0.6/lib/mongo/operation/executable.rb:34:inexecute'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/mongo-2.0.6/lib/mongo/operation/write/insert.rb:72:in execute_write_command'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/mongo-2.0.6/lib/mongo/operation/write/insert.rb:62:inexecute'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/mongo-2.0.6/lib/mongo/collection.rb:190:in insert_many'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/mongo-2.0.6/lib/mongo/collection.rb:175:ininsert_one'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-mongodb-0.1.4/lib/logstash/outputs/mongodb.rb:56:in receive'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.2.2-java/lib/logstash/outputs/base.rb:88:inhandle'", "(eval):513:in output_func'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.2.2-java/lib/logstash/pipeline.rb:243:inoutputworker'", "/opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.2.2-java/lib/logstash/pipeline.rb:165:in start_outputs'"], :level=>:warn}
NoMethodError: undefined methoderror_code' for #
receive at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-output-mongodb-0.1.4/lib/logstash/outputs/mongodb.rb:60
handle at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.2.2-java/lib/logstash/outputs/base.rb:88
output_func at (eval):513
outputworker at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.2.2-java/lib/logstash/pipelinestrong text.rb:243
start_outputs at /opt/logstash/vendor/bundle/jruby/1.9/gems/logstash-core-1.5.2.2-java/lib/logstash/pipeline.rb:165
`
Any idea to solve this issue please ?
Thanks !
I have this same error when logstash mongoldb output configuration has
isodate => true
I have no arrays in my data. Just Nginx access-log data. When I output my data with
stdout { codec => rubydebug }
#timestamp looks like this
{
"#timestamp" => "2015-09-16T18:49:11.347Z",
}
Main issues is that when I output this to mongodb, the data is inserted as string with quotes escaped like this:
"#timestamp": "\"2015-09-16T18:14:06.178Z\"",
I'm using logstash 1.5.4 and mongodb 3.0.6, and the error I'm getting is
:exception=>#<NoMethodError: undefined method `bson_type' for "2015-09-16T18:33:52.474Z":LogStash::Timestamp>, :backtrace=>["/opt/logstash/vendor/bundle/jruby/1.9/gems/bson-3.2.4-java/lib/bson/hash.rb:44:in `to_bson'", [...]
I haven't found any solution for this yet.

MongoDB Ruby driver and mongoS

I am trying to use the MongoDB Ruby driver to pull information from a cluster via mongoS. Here is what I've done.
#mongo_client = Mongo::Connection.new('mongoshost', 27320)
#db = #mongo_client.db("thedatabase")
#auth = #db.authenticate("username", "password")
if(#mongo_client)
print "Successfully connected to mongos\n"
else
print "Connection failed"
end
if(#auth == true)
print "Auth successful\n"
else
print "Auth failed"
end
collection = #db.collection("thecollection")
puts collection.find.to_a
When I run this, everything works up until the point that it tries to print the documents in the collection. Here's what my output looks like:
C:\Code\whatever>ruby getdata.rb
Successfully connected to mongos
Auth successful
C:/Ruby200/lib/ruby/gems/2.0.0/gems/bson-1.9.2/lib/bson/bson_c.rb:24:in `deseria
lize': time must be positive (ArgumentError)
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/bson-1.9.2/lib/bson/bson_c.rb:2
4:in `deserialize'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/mongo-1.9.2/lib/mongo/networkin
g.rb:223:in `read_documents'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/mongo-1.9.2/lib/mongo/networkin
g.rb:169:in `receive'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/mongo-1.9.2/lib/mongo/networkin
g.rb:133:in `receive_message'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/mongo-1.9.2/lib/mongo/cursor.rb
:497:in `block in send_initial_query'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/mongo-1.9.2/lib/mongo/util/logg
ing.rb:55:in `block in instrument'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/mongo-1.9.2/lib/mongo/util/logg
ing.rb:20:in `instrument'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/mongo-1.9.2/lib/mongo/util/logg
ing.rb:54:in `instrument'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/mongo-1.9.2/lib/mongo/cursor.rb
:493:in `send_initial_query'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/mongo-1.9.2/lib/mongo/cursor.rb
:478:in `refresh'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/mongo-1.9.2/lib/mongo/cursor.rb
:124:in `next'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/mongo-1.9.2/lib/mongo/cursor.rb
:290:in `each'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/mongo-1.9.2/lib/mongo/cursor.rb
:314:in `to_a'
from C:/Ruby200/lib/ruby/gems/2.0.0/gems/mongo-1.9.2/lib/mongo/cursor.rb
:314:in `to_a'
from getdata.rb:27:in `<main>'
The "time must be positive" error had a few search results, but nothing that helped me figure out what the issue is. One of the fields in these documents does hold a negative number for a date, but I'm not sure why that's an issue since it's reading it and not writing (For example, one of the fields looks like so: {"md" : Date(-62135596800000)})
Is this an issue with the driver, is my code bad, or do I need to figure this out in another manner? I'm pretty new to ruby so any help would be appreciated!
Your data is bad as you have already noted. The problem is that the driver is trying to expand the date value ( which is really just a number internally to mongo within a BSON timestamp field ) into a real DateTime object.
When it tries to do this on read, the number is invalid an the inflation fails. If you fix the date value the problem will be corrected.
Note: If you do this in the shell use the ISOate helper to put a correct value in. If you use code then use a DateTime object. Don't use strings as you will mess your data up further.

I get these errors trying to build a web service client in Ruby

I am trying to build a web service client in Ruby.
When I try to invoke the following soap4r ruby script to generate web service client code:
wsdl2ruby.rb --wsdl *[web_service_url]* --type client
I get the following error:
ignored attr: {http://www.w3.org/2006/05/addressing/wsdl}Action
I, [2011-06-09T17:16:01.012268 #10104] INFO -- app: Creating class definition.
I, [2011-06-09T17:16:01.012268 #10104] INFO -- app: Creates file 'SessionServic
e.rb'.
F, [2011-06-09T17:16:01.014268 #10104] FATAL -- app: Detected an exception. Stop
ping ... undefined method collect' for #<String:0x32260c8> (NoMethodError)
C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/xsd/codegen/gensupport.rb:2
39:intrim_eol'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/xsd/codegen/gensupport.rb:2
27:in format'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/xsd/codegen/commentdef.rb:2
7:indump_comment'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/xsd/codegen/classdef.rb:51:
in dump'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/classDefCreator.r
b:118:inblock in dump_complextype'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/classDefCreator.r
b:116:in collect'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/classDefCreator.r
b:116:indump_complextype'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/classDefCreator.r
b:60:in dump'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/wsdl2ruby.rb:77:i
nblock in create_classdef'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/wsdl2ruby.rb:171:
in block in write_file'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/wsdl2ruby.rb:170:
inopen'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/wsdl2ruby.rb:170:
in write_file'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/wsdl2ruby.rb:76:i
ncreate_classdef'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/wsdl2ruby.rb:62:i
n create_file'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/soap/wsdl2ruby.rb:42:i
nrun'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/bin/wsdl2ruby.rb:46:in run'
C:/Ruby192/lib/ruby/1.9.1/logger.rb:691:instart'
C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/bin/wsdl2ruby.rb:137:in <top (
required)>'
C:/Ruby192/bin/wsdl2ruby.rb:19:inload'
C:/Ruby192/bin/wsdl2ruby.rb:19:in `'
I, [2011-06-09T17:16:01.016268 #10104] INFO -- app: End of app. (status: -1)
When, I try to invoke the following code to dynamically generate the web service client:
require 'soap/wsdlDriver'
WSDL_URL = "http://*[web_service_url]*"
factory = SOAP::WSDLDriverFactory.new(WSDL_URL)
driver = factory.create_rpc_driver
I get the following error:
C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:748:in initialize': The requested service
provider could not be loaded or
initialized. - socket(2)
(http://*web_service_url*) (Errno::E10106)
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:748:innew' from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:748:in create_socket' from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:705:inblock in connect' from
C:/Ruby192/lib/ruby/1.9.1/timeout.rb:57:in
timeout' from
C:/Ruby192/lib/ruby/1.9.1/timeout.rb:87:in
timeout' from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:704:in connect' from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:568:inquery' from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:158:in query' from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:1057:in
do_get_block' from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:866:in
block in do_request' from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:953:in
protect_keep_alive_disconnected'
from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:865:in
do_request' from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:938:in
follow_redirect' from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:577:in
get_content' from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/xmlSchema/importer.rb:73:in
fetch' from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/xmlSchema/importer.rb:36:in
import' from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/importer.rb:18:in
import' from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/soap/wsdlDriver.rb:146:in
import' from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/soap/wsdlDriver.rb:32:in
initialize' from
C:/DevProjects/application-development-environment/UwsSampleRuby/blah.rb:6:in
new' from
C:/DevProjects/application-development-environment/UwsSampleRuby/blah.rb:6:in
'
When I try to invoke the same code above, but with the a different URL (the production URL instead of the test environment URL), I get a different error:
C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:748:in initialize': getaddrinfo: A non-recoverable error occurred during a database lookup. (https://[prod_url]:443) (SocketError)
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:748:innew'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:748:in create_socket'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:705:inblock in connect'
from C:/Ruby192/lib/ruby/1.9.1/timeout.rb:57:in timeout'
from C:/Ruby192/lib/ruby/1.9.1/timeout.rb:87:intimeout'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:704:in connect'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:568:inquery'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient/session.rb:158:in query'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:1057:indo_get_block'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:866:in block in do_request'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:953:inprotect_keep_alive_disconnected'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:865:in do_request'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:938:infollow_redirect'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/httpclient-2.2.1/lib/httpclient.rb:577:in get_content'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/xmlSchema/importer.rb:73:infetch'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/xmlSchema/importer.rb:36:in import'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/wsdl/importer.rb:18:inimport'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/soap/wsdlDriver.rb:146:in import'
from C:/Ruby192/lib/ruby/gems/1.9.1/gems/soap4r-1.5.8/lib/soap/wsdlDriver.rb:32:ininitialize'
from C:/DevProjects/application-development-environment/UwsSampleRuby/blah.rb:6:in new'
from C:/DevProjects/application-development-environment/UwsSampleRuby/blah.rb:6:in'
Why am I getting these errors, and how do I work around them? I know the web services are up and working, since I'm able to build web service clients in C# .Net just fine.
soap4r has a number of known issues with Ruby 1.9. You should consider using one of the newer SOAP toolkits, such as savon or handsoap.

Resources