Questions tagged [gen-server]

gen_server stands for "generic server", a module behaviour in Erlang.

315 questions
0
votes
2 answers

How do I update my PID on a timer?

I am trying to update my process's state on a 10 second timer. -define(INTERVAL, 3000). start_link() -> gen_server:start_link(?MODULE, [], []). action(Pid, Action) -> gen_server:call(Pid, Action). init([]) -> erlang:send_after(?INTERVAL,…
quantumpotato
  • 9,637
  • 14
  • 70
  • 146
0
votes
1 answer

How can I update color of button in real time?

I have an index page, when a user logs in, it shows all tables (button of tables) in the database.Table can have an order. So, it works like when a user clicks a table, it redirects to the create path of order and create an order. Or if a table has…
D.R
  • 829
  • 4
  • 16
  • 30
0
votes
0 answers

Elixir GenServer: Undefined Returned on Call after a Cast

I'm working through the examples in Programming Elixir by Dave Thomas (Pragmatic Bookshelf). I've been using the REPL at http://tryelixir.online/, and have also tried Wandbox with the same results on this particular issue. defmodule Sequence.Server…
user6900229
0
votes
1 answer

Unable to start supervisor: (Protocol.UndefinedError) protocol Enumerable not implemented for

I am trying to start a Supervisor and a GenServer: defmodule SubscriptionManagerSupervisor do use Supervisor def start_link do Supervisor.start_link(__MODULE__, [], [{:name, __MODULE__}]) end # supervisor callback def init([]) do …
sheldonkreger
  • 858
  • 1
  • 9
  • 25
0
votes
1 answer

process "events" async with elixir and phoenix

I'm using phoenix controllers to receive data via REST calls. So an iOS app could send the "events" for each user and based on the event, I need to calculate the score/points and send it back to the user. Calculation and sending back to the user can…
ed1t
  • 8,719
  • 17
  • 67
  • 110
0
votes
2 answers

A single erlang process eating up more memory and firing process memory high alarms

I have an erlang gen_server which receives messages from clients asynchronously(using cast). On each message handling, the server inserts them into a ordered ETS table and deletes some of them based on conditions (Because of the conditional delete,…
0
votes
1 answer

Processing data under load with GenServer (gen_server)

I am testing the following pattern in a GenServer: def handle_info({:tcp, _, data}, s) do # IO.puts "\nrx: \n#{Base.encode16(data)}\n" extra = _proc_data(<>) :inet.setopts(s.socket, active: :once) …
Charles Okwuagwu
  • 10,538
  • 16
  • 87
  • 157
0
votes
1 answer

Erlang supervisor/gen_server exception exit: noproc

I'm going insane right now trying to figure out what the problem to this is. Basically I just want to set up an easy Supervisor with 1 server and 1 gen_event-behaviour module. Now the problem is that I can't get it to start anymore, the supervisor…
Klesken
  • 35
  • 1
  • 6
0
votes
1 answer

Kill all gen_server by supervisor in Erlang

In Erlang, I have a supervisor (my_sup) module to starts and monitor the gen_server process (my_gen). When the my_gen is modified, compiled and loaded, I need to restart the application. Is there any better way to kill all the process (gen_server)…
Yarin Nim
  • 3,607
  • 3
  • 14
  • 15
0
votes
1 answer

What code will recover from ** Removing (timedout) connection **?

I have a gen_server on one system and 4 clients on 4 other systems. The code runs as expected for 3 or 4 days when the gen_server reports "** Removing (timedout) connection **". Because the clients can become active before of after the start of the…
Bill Ott
  • 15
  • 4
0
votes
1 answer

Gen_tcp over gen_server socket listen closed immediatly

I want to use gen_tcp over gen_server, here is the code: start_link() -> io:format("start_link~n"), gen_server:start_link({global, ?MODULE}, ?MODULE, [], []). init([]) -> {ok,ListenSocket} = gen_tcp:listen(8091, [{active,true}, binary]), …
J.R.
  • 2,335
  • 2
  • 19
  • 21
0
votes
1 answer

Confusion regarding abcast function and uniqueness of gen_server names

From erlang.org/doc, the gen_server section: start_link(ServerName, Module, Args, Options) -> Result If there already exists a process with the specified ServerName the function returns {error,{already_started,Pid}} Apparently, Erlang does not…
adizere
  • 224
  • 1
  • 10
0
votes
2 answers

gen_server handle_info/2 clarification

While reading through Erlang and OTP in action, I ran across some weird syntax regarding records that I'm having trouble wrapping my head around. I'm hoping someone can clarify what's going on in the handle_info for timeouts here: handle_info({tcp,…
billcobbler
  • 315
  • 1
  • 8
0
votes
1 answer

Erlang inets httpc connect to local inets httpd

I'm trying to implement a module with httpd, which handles HTTP get request for a process. Basically it handles the incoming get request, parses the get parameters and calls a synchronous gen_server method on the node, which started the http server.…
balcsok
  • 33
  • 2
  • 11
0
votes
1 answer

Erlang tcp server vote kicking

I'm attempting to write a simple vote kicking option to add to my existing server. I have a message router using gen_server and this stores all connected clients using init([]) -> {ok, dict:new()}. The router is separate from the tcp server which…
SharkBytes
  • 211
  • 4
  • 18
1 2 3
20
21