-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently apply
Description
Nick Williams opened SPR-10611 and commented
I created the following class:
@ServerEndpoint(value = "/chat/{sessionId}",
encoders = ChatMessageDecoderCodec.class,
decoders = ChatMessageDecoderCodec.class,
configurator = SpringConfigurator.class)
public class ChatEndpoint
{
...
@Inject SessionRegistry sessionRegistry;
@Inject ChatService chatService;
...
@Scheduled(fixedDelay = 25_000L, initialDelay = 25_000L)
public void sendPing()
{
log.info("Sending ping to WebSocket client.");
try
{
this.wsSession.getBasicRemote()
.sendPing(ByteBuffer.wrap(ChatEndpoint.pongData));
}
catch(IOException e)
{
log.warn("Failed to send ping message to WebSocket client.", e);
}
}
...
@PostConstruct
public void initialize()
{
this.sessionRegistry.registerOnRemoveCallback(this::httpSessionRemoved);
}
}When I connect to the WebSocket connection, the @Inject dependencies get properly injected and the initialize method gets properly called. However, the @Scheduled method never executes. A @Scheduled method on a separate @Service executes just fine (so my scheduler/executor are configured correctly), but not the method on the endpoint.
This is likely to be a common use case. Pings need to be sent periodically to keep connections alive, and @Scheduled is the perfect way to do this. Whatever is keeping this from working should be resolved.
Affects: 4.0 M1
Issue Links:
- SpringConfigurator uses ListableBeanFactory method which is documented to be slow for EVERY new WebSocket connection [SPR-10605] #15234 SpringConfigurator uses ListableBeanFactory method which is documented to be slow for EVERY new WebSocket connection
0 votes, 5 watchers
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)status: declinedA suggestion or change that we don't feel we should currently applyA suggestion or change that we don't feel we should currently apply