WebSockets support

48 views
Skip to first unread message

Ori S

unread,
Dec 29, 2018, 5:43:03 PM12/29/18
to RestExpress
Hi.

I've been using RestExpress for a couple of years now, and it's been serving me very well. I'd like to continue using it when offering WebSockets support for clients.

I would like to add support for this in RestExpress as I saw many others have already coded this for Netty, so I'd guess that we'll just need to wrap things a bit so to be RE-compliant.

Any pointers on where to start and how to tackle this? Might you suggest also an interface/classes/methods to add where to plug them up? I'll code the rest.

Thanks for your help!

/OriS

Todd Fredrich

unread,
Jan 13, 2021, 3:31:34 PM1/13/21
to RestExpress
Thanks for reaching out!
My experience with WebSockets lead me to believe that mixing them with HTTP on the same Netty pipeline would be problematic (although I could be wrong). For example, AWS API gateway has a completely different gateway implementation to handle WebSockets and HTTP requests.

All that being said, it could be argued that a WebSocket-based Netty pipeline could be really handy for browser-based applications! However, I have no experience using Netty for handling WebSockets. My guess is there's a fair amount of tooling for it and my guess is you'd use WebSocket-specific handlers in the Netty pipeline instead of HTTP-specific handlers. For example, in https://github.com/RestExpress/RestExpress/blob/master/core/src/main/java/org/restexpress/pipeline/PipelineInitializer.java initChannel(SocketChannel ch) method, replacing the 'decoder' and 'encoder' pipeline elements. But I'm only guessing.

There might also need to be different handling of content-type, etc. in the DefaultRequestHandler which is stitched-in in the RestExpress.java class--so maybe a WebSocketRequestHandler.

I haven't looked into handling WebSockets on Netty, but perhaps someone here can be more helpful... :)

Thanks,
--Todd

Reply all
Reply to author
Forward
0 new messages