phoenix_gen_socket_client icon indicating copy to clipboard operation
phoenix_gen_socket_client copied to clipboard

Client unable to reply to server push messages

Open kerrd89 opened this issue 2 years ago • 1 comments

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 the handle_reply method in the client. But the client cannot respond to push messages from the server. The messages come into the handle_message method for the client, which does not have the from input. The documentation for the client reply is asking for a from GenServer input which doesn't exist on handle_message.

Attempts to reply with anything else than {:ok, state} or {:connect, state} returns an error from the handle_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?

kerrd89 avatar Nov 23 '22 15:11 kerrd89