Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when subscribing to "$local" topic #35

Open
BorisPetelj opened this issue Jan 17, 2018 · 2 comments
Open

Error when subscribing to "$local" topic #35

BorisPetelj opened this issue Jan 17, 2018 · 2 comments
Assignees
Labels

Comments

@BorisPetelj
Copy link

BorisPetelj commented Jan 17, 2018

Using emq_web_hook with emqttd 2.3.3.
When client subscribes to topic "$local/$share/group/#" it gets disconnected with error in emqttd log:

2018-01-17 15:04:23.697 [error] <0.4767.0> gen_server <0.4767.0> terminated with reason: no function clause matchin
767.0> terminated with reason: no function clause matchin
g mochijson2:'-json_encode_proplist/2-fun-0-'(local, [44,[34,<<"all">>,34],58,[34,<<"share">>,34],44,"0",58,[34,<<"
qos">>,34],123]) line 206
2018-01-17 15:04:23.697 [error] <0.4767.0> CRASH REPORT Process <0.4767.0> with 0 neighbours exited with reason: no
 function clause matching mochijson2:'-json_encode_proplist/2-fun-0-'(local, [44,[34,<<"all">>,34],58,[34,<<"share"
>>,34],44,"0",58,[34,<<"qos">>,34],123]) line 206 in gen_server2:terminate/3 line 1157
2018-01-17 15:04:23.697 [error] <0.4564.0> Supervisor 'esockd_connection_sup - <0.4564.0>' had child connection sta
rted with emqttd_client:start_link([{max_publish_rate,0},{client_idle_timeout,30000},{client_enable_stats,false},{max_clientid_len,...},...]) at <0.4767.0> exit with reason no function clause matching mochijson2:'-json_encode_proplist/2-fun-0-'(local, [44,[34,<<"all">>,34],58,[34,<<"share">>,34],44,"0",58,[34,<<"qos">>,34],123]) line 206 in context connection_crashed

If the topic is "$share/group/#" client subscribes normally.
$local prefix is needed for load-balancing in a cluster mode.
@emqplus

@emqplus emqplus self-assigned this Jan 23, 2018
@emqplus emqplus added the bug label Jan 23, 2018
@BorisPetelj
Copy link
Author

Any updates on this issue @emqplus ?

@BorisPetelj
Copy link
Author

I found out that a problem is in the parsing of payload before issuing http request. Specifically, mochijson2:encode(Params) in send_http_request function.

The params object for basic topic looks like:
The params are: [{action,client_subscribe}, {client_id,<<"clientId">>}, {username,<<"user">>}, {topic,<<"topic">>}, {opts,[{qos,0}]}].

While params object for topic with prefix '$local/$share' looks like:
The params are: [{action,client_subscribe}, {client_id,<<"clientId">>}, {username,<<"username">>}, {topic,<<"topic">>}, {opts,[{qos,0},{share,<<"udm">>},local]}].

Even tough i'm not familiar to Erlang, it seems that opts object in the latter case is not valid. The property 'local' is not wrapped correctly.

@gilbertwong96 gilbertwong96 self-assigned this Aug 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants