-
Notifications
You must be signed in to change notification settings - Fork 82
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bandit intercepting liveview send/2 messages #141
Comments
Is this a websocket or long poll based liveview? |
Try it like this: def mount(
%{"id" => id},
_session,
%{assigns: %{current_user: current_user}} = socket
) do
user = Accounts.get_by_username!(id)
if connected?(socket), do: send(self(), {:update_user_view_count, user.id})
{:ok,
socket}
end If the LiveView isn't connected yet, your |
This is websocket
will try this and report back! thank! |
See https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html#connected?/1 for docs on this; I think this ought to be more prominent in the live view docs (or maybe even a explicit flag that gets passed to mount) as it's an easy point of confusion. Closing since I'm 99% sure that @moogle19's advice will work. If not, feel free to reopen! |
Related to mtrudel/bandit#141, we get into this situation when we close the connection before truly entering the hibernate loop. Instead, we close/unsubscribe directly, and return the conn immediately. Sample error from `api-prod` (truncated): ``` Bandit.HTTP1.Handler #PID<0.5319.7> received unexpected message in handle_info/2: {:close, <conn>} ```
Related to mtrudel/bandit#141, we get into this situation when we close the connection before truly entering the hibernate loop. Instead, we close/unsubscribe directly, and return the conn immediately. Sample error from `api-prod` (truncated): ``` Bandit.HTTP1.Handler #PID<0.5319.7> received unexpected message in handle_info/2: {:close, <conn>} ```
Related to mtrudel/bandit#141, we get into this situation when we close the connection before truly entering the hibernate loop. Instead, we close/unsubscribe directly, and return the conn immediately. Sample error from `api-prod` (truncated): ``` Bandit.HTTP1.Handler #PID<0.5319.7> received unexpected message in handle_info/2: {:close, <conn>} ```
Hi again!
in our app, we are using liveview, and we are using send/2 and handl_info in
:liveview
after switch to bandit, we been noticing that bandit is intercepting the handle_info call within the liveview
here is how the code is being called in our liveview
any guidance is appreciated
The text was updated successfully, but these errors were encountered: