Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Netty based server in servlet container

I have a network server that was implemented using Jboss Netty. It servers the application over both raw TCP and HTTP and running as a stand alone process. Clients connected with TCP can transfer data to clients connected with HTTP and vice versa.

Now I'm required to make it work in servlet environment. Does netty provide a standard way for doing so or that I have to write my adapter? What can I do with the TCP transport? can I include it in the servlet container ?

this is a similar question but without a clear answer

like image 891
ApriOri Avatar asked Aug 27 '26 02:08

ApriOri


1 Answers

You can create an HttpTunnelingServlet that links to your existing Netty implementation. See the org.jboss.netty.channel.socket.http API docs.

This document uses a Spring bean to do the Netty setup. But, it should be easy enough to move your configuration and setup to a ServletListener. I am not 100% sure if this will work though since the setup needs to connect to a LocalAddress that's specified in the servlet config. The issue may be that the address is not valid until the servlet starts up, which happens, I think, after listeners start. Another option would be to sublcass HttpTunnelingServlet and add to the init() implementation.

Whatever method you use, you will still have to setup and also start the TCP channels, etc too like you were doing before.

like image 184
AngerClown Avatar answered Aug 29 '26 17:08

AngerClown



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!