我正在研究 MQTT 代理 ( http://www.emqtt.io ),它是用 Erlang 编写的。我有一个用例,我需要从用 erlang 编写的 emqtt 代理代码中调用我的一个 python 模块。
我已经检查了谷歌关于erlport ( http://erlport.org/ ) 的信息,它用于 erlang 和 python 之间的端口通信。它在 erlang shell 中运行良好,但是当我在 emqtt erlang 代码中使用它时,它就不起作用了。它抛出如下所示的错误
17:22:40.073 <0.717.0> [error] gen_server <0.717.0> terminated with reason: call to undefined function python:start()
17:22:40.073 <0.717.0> [error] CRASH REPORT Process <0.717.0> with 1 neighbours exited with reason: call to undefined function python:start() in gen_server2:terminate/3 line 1151
17:22:40.073 <0.631.0> [error] Supervisor emqttd_session_sup had child session started with {emqttd_session,start_link,undefined} at <0.717.0> exit with reason call to undefined function python:start() in context child_terminated
17:22:40.073 <0.677.0> [error] Supervisor 'esockd_connection_sup - <0.677.0>' had child connection started with emqttd_client:start_link([{packet,[{max_clientid_len,512},{max_packet_size,65536}]},{client,[{idle_timeout,30}]},{session,...},...]) at <0.716.0> exit with reason call to undefined function python:start() in context connection_crashed
我们正在从 emqtt 插件代码中调用 python 模块,代码更改如下所示
on_message_acked(ClientId, Message, _Env) ->
io:format("client ~s acked: ~s~n", [ClientId, emqttd_message:format(Message)]),
io:format("client ~s",[python:start()]),
{ok, Message}.
请帮助我们。