vttranlina commented on PR #2561: URL: https://github.com/apache/james-project/pull/2561#issuecomment-2533775671
After testing, here is my result: ## For case Client send PING, Server response PONG With the current master code, when a client sends a PING, the James netty websocket server automatically responds with a PONG (as per RFC https://datatracker.ietf.org/doc/html/rfc6455#section-5.5.3), we don't need change anything in source code. Because `WebsocketServerSpec` is `handlePing(false)` by default. If we change the spec to `WebsocketServerSpec.builder.handlePing(true).build`, we must manually code James to respond with `PONG`. The code looks like this: ``` SFlux(in.receiveFrames()) .flatMap(frame => { if (frame.isInstanceOf[PingWebSocketFrame]) { SMono.just(new PongWebSocketFrame()) } else { .... } }) ``` If we don't respond with PONG, the client will automatically close the connection (according to my tests with `OkHttpClient`). ## For case Server send PING, Client response PONG In the last my commit (this pr), I implemented the "unstandard" Ping frame, which is a "text" frame with the content "ping." As rfc 6455 ``` The Ping frame contains an opcode of 0x9. The Pong frame contains an opcode of 0xA. ``` => We should use `io.netty.handler.codec.http.websocketx.PingWebSocketFrame` for ping frames. During testing, I found that the client automatically responded with a `PongWebSocketFrame`. The `OkHttpClient` library handles this automatically (similar with `Postman`) ## Summary: - For the case where the client sends a PING, we can add more tests for confirmation without changing the production code. - For the scenario where the server sends a PING, I'm unclear why mobile to send an "Echo" (text frame) interval; anw, the server send `PingWebSocketFrame` make sense for James. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
