How to send un-solicited data when using WebSockets

I have a WebSocket client server based on the example code that is basically working. Client can connect and send request. The server responds, all all is happy. There are two pipeline handlers, BackPressureHandler and my custom ChannelInboundHandler.

Sometimes my server needs to send data to the client that has not been requested. So, what is the strategy to send data from outside of the Channel handler and not in response to an inbound request?

I feel like I am missing something pretty simple.

To send data from outside a ChannelHandler, you can use Channel.writeAndFlush.

1 Like

That did It. Not sure why I was so dense, but I was trying to save a reference to Context which did not work. Thanks.