I am using {tortoise: "~> 0.9"} on a nerves project when I boot the device in shell and try simple connection over tcp by
defmodule MMod.Mqtt do
require Logger
use GenServer
def start_link(opts \\ []) do
GenServer.start_link(__MODULE__, :ok,opts)
end
def init(:ok) do
IO.puts("starting mqtt")
{:ok,pid}=Tortoise.Supervisor.start_child(
client_id: Application.get_env(:hello_network,:client_id),
handler: {Tortoise.Handler.Logger, []},
server: {Tortoise.Transport.Tcp, host: Application.get_env(:hello_network,:mqtt_host), port: String.to_integer(Application.get_env(:hello_network,:port))}
)
{:ok,pid}
end
def handle_call({:simple_call}, from, state) do
{:reply,from,state}
end
def handle_cast({:simple_cast}, from, state) do
{:noreply,[]}
end
def handle_info(msg, state) do
case msg do
_ -> Tortoise.publish(Application.get_env(:hello_network,:client_id),Application.get_env(:hello_network,:topic),":mymsg", qos: 2)
{:noreply,state}
end
end
end
** (EXIT) no process the process is not alive or there is no process currently associated with given name possibly because its application isn't started
(elixir) lib/gen_server.ex 979 GenServer.call/3
I am able to connect to server with same in normal mix project on host machine. I am using
I am using
{tortoise: "~> 0.9"}
on a nerves project when I boot the device in shell and try simple connection over tcp byMy values for getting fetched as
client_id : "my_client" mqtt_host: "iot.eclipse.org" port: 1883
I am getting this
I am able to connect to server with same in normal mix project on host machine. I am using
Erlang OTP/ 21
andElixir (1.8.1)