gausby / tortoise

A MQTT Client written in Elixir
Apache License 2.0
314 stars 54 forks source link

(CaseClauseError) no case clause matching: {:error, :badarg} #99

Closed citymonitor closed 5 years ago

citymonitor commented 5 years ago

Hi there,

I'm trying to get Tortoise to run for publishing to a MQTT server. If I simply try in iex: {ok, _pid} = Tortoise.Connection.start_link( client_id: "HelloWorld", server: {Tortoise.Transport.Tcp, host: "localhost", port: 1883}, handler: {Tortoise.Handler.Logger, []})

I'm getting:


19:20:02.017 [info]  Initializing handler

19:20:02.018 [error] GenStateMachine {Tortoise.Registry, {Tortoise.Connection.Inflight, "HelloWorld"}} terminating
** (ErlangError) Erlang error: {:bad_action_from_state_function, {:next_events, :internal, :post_init}}
    (stdlib) gen_statem.erl:1299: :gen_statem.parse_actions_next_event/7
    (stdlib) gen_statem.erl:1194: :gen_statem.loop_event_actions_list/10
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Callback mode: :handle_event_function
Last event: {:internal, :init_state}
State: {:disconnected, %Tortoise.Connection.Inflight{client_id: "HelloWorld", order: [], pending: %{}}}

19:20:02.019 [info]  Initializing handler
** (EXIT from #PID<0.367.0>) shell process exited with reason: an exception was raised:
    ** (CaseClauseError) no case clause matching: {:error, :badarg}
        (tortoise) lib/tortoise/connection/receiver.ex:37: Tortoise.Connection.Receiver.handle_socket/2
        (tortoise) lib/tortoise/connection.ex:623: Tortoise.Connection.init_connection/2
        (tortoise) lib/tortoise/connection.ex:386: Tortoise.Connection.handle_info/2
        (stdlib) gen_server.erl:616: :gen_server.try_dispatch/4
        (stdlib) gen_server.erl:686: :gen_server.handle_msg/6
        (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3

Interactive Elixir (1.6.4) - press Ctrl+C to exit (type h() ENTER for help)
iex(15)> 
19:20:02.020 [error] GenServer {Tortoise.Registry, {Tortoise.Connection, "HelloWorld"}} terminating
** (CaseClauseError) no case clause matching: {:error, :badarg}
    (tortoise) lib/tortoise/connection/receiver.ex:37: Tortoise.Connection.Receiver.handle_socket/2
    (tortoise) lib/tortoise/connection.ex:623: Tortoise.Connection.init_connection/2
    (tortoise) lib/tortoise/connection.ex:386: Tortoise.Connection.handle_info/2
    (stdlib) gen_server.erl:616: :gen_server.try_dispatch/4
    (stdlib) gen_server.erl:686: :gen_server.handle_msg/6
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Last message: :connect
State: %Tortoise.Connection{backoff: %Tortoise.Connection.Backoff{max_interval: 30000, min_interval: 100, value: nil}, client_id: "HelloWorld", connect: %Tortoise.Package.Connect{__META__: %Tortoise.Package.Meta{flags: 0, opcode: 1}, clean_session: true, client_id: "HelloWorld", keep_alive: 60, password: nil, protocol: "MQTT", protocol_version: 4, user_name: nil, will: nil}, keep_alive: nil, opts: [client_id: "HelloWorld", handler: {Tortoise.Handler.Logger, []}], server: %Tortoise.Transport{host: 'localhost', opts: [:binary, {:packet, :raw}, {:active, false}], port: 1883, type: Tortoise.Transport.Tcp}, status: :down, subscriptions: %Tortoise.Package.Subscribe{__META__: %Tortoise.Package.Meta{flags: 2, opcode: 8}, identifier: nil, topics: []}}

19:20:02.021 [error] GenStateMachine {Tortoise.Registry, {Tortoise.Connection.Inflight, "HelloWorld"}} terminating
** (ErlangError) Erlang error: {:bad_action_from_state_function, {:next_events, :internal, :post_init}}
    (stdlib) gen_statem.erl:1299: :gen_statem.parse_actions_next_event/7
    (stdlib) gen_statem.erl:1194: :gen_statem.loop_event_actions_list/10
    (stdlib) proc_lib.erl:247: :proc_lib.init_p_do_apply/3
Callback mode: :handle_event_function
Last event: {:internal, :init_state}
State: {:disconnected, %Tortoise.Connection.Inflight{client_id: "HelloWorld", order: [], pending: %{}}}

Does anyone have an idea what's wrong here?

ii000314 commented 5 years ago

I have the same problem! Interesting fact: on my Windows WSL (ubuntu 18.04) everything works fine, but on native ubuntu 18.04 I have the same error.

gausby commented 5 years ago

Hi; just to let you know—I am in the middle of moving to a new country, so that is why I haven't been responsive lately. I hope I will get back to it soon—sorry for the wait.

gausby commented 5 years ago

It seems that you are running Elixir 1.6.4; can you try a more recent version and see if the problem persist ?

And sorry for the late reply; life has been eventful lately on my end.

ii000314 commented 5 years ago

Hi, I've fixed the problem by updating Erlang/OTP 19 to Erlang/OTP 21

gausby commented 5 years ago

Awesome ! I'll close the issue then. I'll bump the minimum required Elixir version soonish.