我正在从 GenServer 中的句柄信息功能调用 elixir genserver 以添加电话号码获取表单客户端。但是一旦调用了handle_call,所有者进程就会崩溃[超时]。请帮忙。
全局创建一个 ETS 以在调用任何下述函数之前插入值。
def handle_info(message, state) do
{a,b} = message
phonenumber = b[:body]
add phonenumber
{:noreply, state}
end
def add(phonenumber) do
GenServer.call(__MODULE__, {:add, phonenumber})
end
def handle_call({:add, phonenumber}, from, state) do
:ets.insert(:access_table, {:details, phonenumber})
reply = {:ok, "Added #{phonenumber} to profile"}
new_state = [{username} | state]
{:reply, reply , new_state}
end
错误:
** When Server state == []
** Reason for termination ==
** {timeout,{gen_server,call,['Elixir.Bankrecord',{add,"346534543534"},5000]}}
** (EXIT from #PID<0.150.0>) exited in: :gen_server.call(Bankrecord, {:add, '346534543534'}, 5000)
** (EXIT) time out