# Logstash uses protobuf, running error: NoMethodError", :message=\>"undefined method \`msgclass' for nil:NilClass"

**URL:** <https://discuss.elastic.co/t/logstash-uses-protobuf-running-error-nomethoderror-message-undefined-method-msgclass-for-nil-nilclass/144806>\
**Category:** Logstash\
**Created:** [August 17, 2018, 2:44am UTC](https://discuss.elastic.co/t/logstash-uses-protobuf-running-error-nomethoderror-message-undefined-method-msgclass-for-nil-nilclass/144806 "2018-08-17T02:44:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sun\_changlong](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sun_changlong/32/39036_2.png) [@sun\_changlong](https://discuss.elastic.co/u/sun_changlong)\
**Post date:** [August 17, 2018, 2:44am UTC](https://discuss.elastic.co/t/logstash-uses-protobuf-running-error-nomethoderror-message-undefined-method-msgclass-for-nil-nilclass/144806/1 "2018-08-17T02:44:11Z")

</div>

I use logstash to accept message data in the format protobuf，  
the **protobuf.conf** is setting :

```
input {
  beats {
	port => 5044
	ssl => false
	codec => protobuf {
	  class_name => ["Elk.ElkData"]
	  include_path => ["/home/logstash/test_code/elk.pb.rb"]
	  protobuf_version => 3
	}
	type => "protobuf"
  }
}

output {
  stdout { codec => rubydebug }
}

```

The **elk.pb.rb** file is generated by the " **ruby-protocl elk**" command。elk.pb.rb：

```
#!/usr/bin/env ruby
# Generated by the protocol buffer compiler. DO NOT EDIT!

require 'protocol_buffers'

module Elk
  # forward declarations
  class ElkData < ::ProtocolBuffers::Message; end

  class ElkData < ::ProtocolBuffers::Message
    set_fully_qualified_name "elk.ElkData"

    optional :string, :table, 1
    optional :int64, :start, 2
    optional :int64, :end, 3
    optional :string, :pattern, 4
    optional :string, :columns, 5
    optional :string, :is_statistic, 6
    optional :int32, :top_cols, 7
    optional :string, :stat_cols, 8
    optional :int32, :count, 9
    optional :string, :user, 10
  end

end

```

Run the comment

> bin/logstash -f protobuf.conf

the error :

> [ERROR][logstash.agent] Failed to execute action {:action=\>LogStash::PipelineAction::Create/pipeline\_id:main, :exceptio n=\>"NoMethodError", :message=\>"undefined method `msgclass' for nil:NilClass", :backtrace=>["/home/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-codec-pr otobuf-1.1.0/lib/logstash/codecs/protobuf.rb:101:in `register'", "/home/logstash/logstash-core/lib/logstash/codecs/base.rb:20:in `initialize'", "/home/logs tash/logstash-core/lib/logstash/plugins/plugin_factory.rb:97:in `plugin'", "/home/logstash/logstash-core/lib/logstash/pipeline.rb:110:in `plugin'", "(eval) :8:in `'", "org/jruby/RubyKernel.java:994:in `eval'", "/home/logstash/logstash-core/lib/logstash/pipeline.rb:82:in `initialize'", "/home/logstash/log stash-core/lib/logstash/pipeline.rb:167:in `initialize'", "/home/logstash/logstash-core/lib/logstash/pipeline_action/create.rb:40:in `execute'", "/home/log stash/logstash-core/lib/logstash/agent.rb:305:in `block in converge\_state'"]}

the **msgclass** in /home/logstash/vendor/bundle/jruby/2.3.0/gems/logstash-codec-protobuf-1.1.0/lib/logstash/codecs/protobuf.rb:101 file :

 ![1](https://us1.discourse-cdn.com/elastic/original/3X/4/8/48252d1887954b5dc7b50776ed7b4fab3a8ccd99.jpeg)

**protoc version is libprotoc 3.6.1, and the logstash version is 6.3.0. I can run under the 2.5 version of protoc.**

**I have consulted a lot of information and found no solution. What am I missing or where is the error? Looking forward to your answer**

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [September 14, 2018, 2:44am UTC](https://discuss.elastic.co/t/logstash-uses-protobuf-running-error-nomethoderror-message-undefined-method-msgclass-for-nil-nilclass/144806/2 "2018-09-14T02:44:16Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
