Skip to content

feat(websocket): handle ping messages sent from react and add logging #346

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

Merged
merged 1 commit into from
Apr 10, 2025

Conversation

ym
Copy link
Contributor

@ym ym commented Apr 10, 2025

react-use-websocket' sends a ping' message instead of the control frame defined in RFC6455, as sending the opcode is currently not supported by some browsers.

This PR adds support for ping messages and logging.

@ym ym requested review from adamshiervani and Copilot April 10, 2025 10:58
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

Files not reviewed (1)
  • go.mod: Language not supported

logInfof("ping message received: %s", string(msg))
err = wsCon.Write(context.Background(), websocket.MessageText, pongMessage)
if err != nil {
logWarnf("unable to write pong message: %v", err)
Copy link
Preview

Copilot AI Apr 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error during pong message write may abruptly terminate the connection if encountered. Consider handling the error more gracefully (e.g., logging the error and possibly attempting a retry or closing the connection in a controlled manner).

Suggested change
logWarnf("unable to write pong message: %v", err)
logWarnf("unable to write pong message: %v", err)
closeErr := wsCon.Close(websocket.StatusInternalError, "error writing pong message")
if closeErr != nil {
logWarnf("error closing websocket connection: %v", closeErr)
}

Copilot uses AI. Check for mistakes.

@adamshiervani adamshiervani merged commit 4137b82 into jetkvm:dev Apr 10, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants