The code that is causing issues for me is this:
def websocket_handle({:binary, message}, state) do
supervisor = {Outcall.TaskSupervisor, :"outcall@127.0.0.1"}
Task.Supervisor.async(supervisor, Kernel, :node, []) |> Task.await()
{:reply, {:binary, message}, state}
end
The error is this:
15:56:14.234 [error] Ranch listener Communicate.Router.HTTP had connection process started with :cowboy_clear:start_link/4 at #PID<0.393.0> exit with reason: {:badarg, [{:erlang, :iolist_size, [{:EXIT, #PID<18452.208.0>, :normal}], []}, {:cow_ws, :payload_length, 1, [file: 'experiment/gateway/elixir/deps/cowlib/src/cow_ws.erl', line: 725]}, {:cow_ws, :frame, 2, [file: '/experiment/gateway/elixir/deps/cowlib/src/cow_ws.erl', line: 666]}, {:cowboy_websocket, :websocket_send, 2, [file: 'experiment/gateway/elixir/deps/cowboy/src/cowboy_websocket.erl', line: 626]}, {:cowboy_websocket, :handler_call, 6, [file: '/experiment/gateway/elixir/deps/cowboy/src/cowboy_websocket.erl', line: 542]}, {:cowboy_http, :loop, 1, [file: '/experiment/gateway/elixir/deps/cowboy/src/cowboy_http.erl', line: 254]}, {:proc_lib, :init_p_do_apply, 3, [file: 'proc_lib.erl', line: 249]}]}
Here is the task supervisor on outcall@127.0.0.1:
{Task.Supervisor, name: Outcall.TaskSupervisor}
]
Supervisor.start_link(children, [strategy: :one_for_one, name: ElixirOutcall.Supervisor])
The interesting this is that the task works fine when run directly from IEx:
iex(communicate@127.0.0.1)6> supervisor = {Outcall.TaskSupervisor, :"outcall@127.0.0.1"}
{Outcall.TaskSupervisor, :"outcall@127.0.0.1"}
iex(communicate@127.0.0.1)7> Task.Supervisor.async(supervisor, Kernel, :node, []) |> Task.await()
:"outcall@127.0.0.1"