Skip to content

Commit

Permalink
Send Pong via scheduler for the session
Browse files Browse the repository at this point in the history
Single threaded scheduler for serial sending, avoiding concurrent
sends that are not allowed by the WebSocket runtime.

Closes gh-793
  • Loading branch information
rstoyanchev committed Sep 15, 2023
1 parent e48004f commit 9d34402
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,15 @@ private void handleInternal(WebSocketSession session, TextMessage webSocketMessa
.publishOn(state.getScheduler()) // Serial blocking send via single thread
.subscribe(new SendMessageSubscriber(id, session, state));
}
case PING -> session.sendMessage(encode(GraphQlWebSocketMessage.pong(null)));
case PING ->
state.getScheduler().schedule(() -> {
try {
session.sendMessage(encode(GraphQlWebSocketMessage.pong(null)));
}
catch (IOException ex) {
ExceptionWebSocketHandlerDecorator.tryCloseWithError(session, ex, logger);
}
});
case COMPLETE -> {
if (id != null) {
Subscription subscription = state.getSubscriptions().remove(id);
Expand Down

0 comments on commit 9d34402

Please sign in to comment.