Telegraph icon indicating copy to clipboard operation
Telegraph copied to clipboard

Bug Report: WebSocket Close Frame Delivered via didReceiveMessage Delegate

Open thuongvovan opened this issue 8 months ago • 0 comments
trafficstars

Description: When using the Telegraph WebSocket server with a browser client, we observe that the server sends a close frame (opcode: connectionClose, payload: close 1001) which is being delivered through the didReceiveMessage delegate method. This is causing confusion as the message appears in the same stream as regular data messages.

Issue:

  • The close frame indicating “Going Away” (close code 1001) is not clearly distinguished from normal data messages.
  • This behavior may lead to improper handling of the disconnection event on the client side, as browsers expect control frames (like close) to trigger dedicated disconnect callbacks.

Proposed Improvement:

  • Separate the processing of control messages (e.g., connection close, ping/pong) from data messages.
  • Introduce a dedicated callback (or modify existing ones) to handle connection close events, ensuring that control frames are processed distinctly from regular messages.

Impact: This change will help ensure that browser clients can correctly distinguish between normal message content and control events, leading to more robust error handling and cleaner separation of concerns in the client implementation.

Please review and consider this enhancement for improved clarity and reliability in our WebSocket communication.

thuongvovan avatar Feb 22 '25 09:02 thuongvovan