RubyDevInc / paho.mqtt.ruby

Eclipse Public License 1.0
31 stars 19 forks source link

undefined method `to_sym' for 5:Integer (NoMethodError) when unauthorised #28

Open rgaufman opened 6 years ago

rgaufman commented 6 years ago

I added this to my mosquitto broker config:

password_file /etc/mosquitto/passwd
allow_anonymous false

When I try to connect with paho without supplying a password, I get:

Traceback (most recent call last):
    5: from ./bin/publisher-main.rb:9:in `<main>'
    4: from /usr/local/lib/ruby/gems/2.6.0/gems/paho-mqtt-1.0.7/lib/paho_mqtt/client.rb:113:in `connect'
    3: from /usr/local/lib/ruby/gems/2.6.0/gems/paho-mqtt-1.0.7/lib/paho_mqtt/connection_helper.rb:43:in `do_connect'
    2: from /usr/local/lib/ruby/gems/2.6.0/gems/paho-mqtt-1.0.7/lib/paho_mqtt/handler.rb:45:in `receive_packet'
    1: from /usr/local/lib/ruby/gems/2.6.0/gems/paho-mqtt-1.0.7/lib/paho_mqtt/handler.rb:88:in `handle_connack'
/usr/local/lib/ruby/gems/2.6.0/gems/paho-mqtt-1.0.7/lib/paho_mqtt/handler.rb:181:in `handle_connack_error': undefined method `to_sym' for 5:Integer (NoMethodError)
Did you mean?  to_s

There should maybe be a more graceful and descriptive error?

p-goudet commented 6 years ago

Could you confirm that this issue has been fixed as well?

rgaufman commented 6 years ago

Thank you for the update! - I'm not sure if this is related, but getting this:

Traceback (most recent call last):
    4: from test-paho.rb:40:in `<main>'
    3: from /usr/local/lib/ruby/gems/2.5.0/bundler/gems/paho.mqtt.ruby-4a121dd03a69/lib/paho_mqtt/client.rb:118:in `connect'
    2: from /usr/local/lib/ruby/gems/2.5.0/bundler/gems/paho.mqtt.ruby-4a121dd03a69/lib/paho_mqtt/connection_helper.rb:43:in `do_connect'
    1: from /usr/local/lib/ruby/gems/2.5.0/bundler/gems/paho.mqtt.ruby-4a121dd03a69/lib/paho_mqtt/handler.rb:45:in `receive_packet'
/usr/local/lib/ruby/gems/2.5.0/bundler/gems/paho.mqtt.ruby-4a121dd03a69/lib/paho_mqtt/handler.rb:89:in `handle_connack': uninitialized constant PahoMqtt::Handler::MQTT_CS_DISCONNECTED (NameError)
Did you mean?  PahoMqtt::MQTT_CS_CONNECTED
               PahoMqtt::MQTT_CS_DISCONNECT
p-goudet commented 6 years ago

Um, I think there is typo there. I will fix soon.