You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature Request: Add close_output/2 for Half-Close WebSocket Support #140
Add support for closing only the output side of a WebSocket connection while continuing to receive data from the server. This enables the "half-close" pattern where a client signals it's done sending but
remains open to receive remaining server messages.
Motivation
Some WebSocket-based applications require the client to signal completion of sending data while still needing to receive responses or acknowledgments from the server. Currently, WebSockex.close/2 initiates a
full close handshake that terminates the entire connection.
The half-close pattern allows:
Client sends a close frame to indicate "I'm done sending"
Client continues receiving frames until the server sends its close frame
Connection terminates cleanly after both sides have closed
Proposed API
# Close output with default close frameWebSockex.close_output(pid)# Close output with custom close code and messageWebSockex.close_output(pid,{1000,"Done sending"})
Expected Behavior
close_output/2 sends a WebSocket close frame but keeps the connection open for receiving
After calling close_output, send_frame/2 returns {:error, %WebSockex.NotConnectedError{connection_state: :output_closed}}
The client continues to receive and process incoming frames via callbacks (handle_frame, etc.)
When the server responds with its close frame, the connection terminates normally
Callbacks that try to reply with a frame have their replies silently ignored (logged for debugging)
Use Case
Applications where the client streams data to a server, then waits for the server to finish processing and send final results before disconnecting.
Activity
Add close_output/2 for half-close WebSocket support
Add close_output for half-close WebSocket support (#145)