Skip to content

mqtt_client_simple connection issues #2

@ad-pro

Description

@ad-pro

There is an issue when user try to use mqtt_client_simple:

When user wants to connect to the remove mqtt brocker, he will start mqtt_client_simple.
NOTE: mqtt server is running on a remove machine.

    Props=[{host,"hostName"},{port,1883},{client_id,<<"test_id1">>}].
    mqtt_client_simple:connect(Props).

Ant then he will receive an error message:

** exception exit: {noproc,
                    {gen_server,call,
                     [mqtt_client_sup,
                      {start_child,
                       {<<"test_id1">>,
                        {mqtt_client,start_link,
                         [[{handler,mqtt_client_simple},
                           {handler_state,
                            {mqtt_client_simple,<<"test_id1">>,undefined}},
                           {host,"hostName"},
                           {port,1883},
                           {client_id,<<"test_id1">>}]]},
                        transient,brutal_kill,worker,dynamic}},
                      infinity]}}
     in function  gen_server:call/3 (gen_server.erl, line 188)
     in call from mqtt_client_sup:connect/2 (src/mqtt_client_sup.erl, line 45)`

The reason is that mqtt_client:connect method expected that mqtt_client_sup is started.

There are few options how this could be fixed.

  • Explain this in documentation - simplest and less convenient for the user
  • Automatically start mqtt_clinet_sup when required - downside that it would not be part of the user's supervision tree
  • Implement matt_client_simple as a separate application - probably the best option.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions