Open kerrd89 opened 1 year ago
Hey buddy, you misunderstand the pub/sub pattern indeed. It's not the phoenix implementation.
In pub/sub pattern, server push msg down to the client, but there's no required for client to confirm this msg, it's named subscribe some thing, which called topic in elixir. And, you will find that, in Message Queue like RabbitMQ, it does the same thing. To ensure delivery, client must set ACK before connect to the queue.
Well, finally, socket is duplex, but in App layer in TCP/IP as B/S or C/S arch, server side has no responsibility to send any ACK to client side. Simply, we use WebSocket when we need to push msg without client request before.
So for your problem, you should ask client to send a ack msg to server after receive some msg. Like RabbitMQ did, It's not the specification of pattern.
I am happy to help extend/fix this problem if someone can point me in the right direction.
Perhaps I misunderstand the implementation, but I am bumping into a problem attempting to reply in the client to a message from the server.
The server can respond to
push
messages which come into thehandle_reply
method in the client. But the client cannot respond topush
messages from the server. The messages come into thehandle_message
method for the client, which does not have thefrom
input. The documentation for the clientreply
is asking for afrom
GenServer input which doesn't exist onhandle_message
.Attempts to reply with anything else than
{:ok, state}
or{:connect, state}
returns an error from thehandle_message
in the client and the responses do not make it to the server.I am attempting to use this for realtime messaging. Sending a request to a client to update configuration and wanting to a receive a reply to that message. The work around currently is publishing a different message
#{original_message}_reply
but this feels like it isn't using the built-in benefits of the socket.Any advice? Known shortcomings? Pointers for how one would make this work? Suggestions for improving this project?