J0 / phoenix_gen_socket_client

Socket client behaviour for phoenix channels
MIT License
232 stars 48 forks source link

Handling WebSocket Timeouts and Reconnection in this client #72

Open alexaung98 opened 1 month ago

alexaung98 commented 1 month ago

WebSocket timeout and phoenix_gen_socket_client are not reconnecting to the WebSocket server.

I added a timeout behavior to my server WebSocket in endpoint.ex:

socket "/socket", MyWeb.UserSocket, websocket: [timeout: 30_000], longpoll: false

Expectation

When the server closes the connection, the client should automatically reconnect to the server.

Behavior

The client does not detect that the server has closed the connection and remains in the joined state. As a result, when the server sends a message to the client, the client does not actually receive it.

alexaung98 commented 1 month ago

This was easily can fix regarding this below documentation.

https://hexdocs.pm/phoenix_gen_socket_client/Phoenix.Channels.GenSocketClient.Transport.WebSocketClient.html

So I will close this issue here.

aungmyooo2k17 commented 4 weeks ago

WebSocket timeout and phoenix_gen_socket_client are not reconnecting to the WebSocket server.

I added a timeout behavior to my server WebSocket in endpoint.ex:

socket "/socket", MyWeb.UserSocket, websocket: [timeout: 30_000], longpoll: false

Expectation

When the server closes the connection, the client should automatically reconnect to the server.

Behavior

The client does not detect that the server has closed the connection and remains in the joined state. As a result, when the server sends a message to the client, the client does not actually receive it.

I am having the same issue.

I am using phoenix_gen_socket_client for client side and phoenix/channels for server side. I am facing an issue with {:shutdown, :closed}, my server close the channel if he didn't receive any data during 60s. For simulation purpose I set keepalive time for 120s in my client side. The issue is once server close the channel it suppose to receive handle_channel_closed callback. But it doesn't.

alexaung98 commented 4 weeks ago

This was easily can fix regarding this below documentation.

https://hexdocs.pm/phoenix_gen_socket_client/Phoenix.Channels.GenSocketClient.Transport.WebSocketClient.html

So I will close this issue here.

This one also no help