In principle WebSockets can co-exist with other HTTP traffic over ports 80 and 443 and firewalls need not be reconfigured. But I fail to achieve binding to port 80 with the ServerBootstrap methods.
bootstrap.group(new NioEventLoopGroup(), new NioEventLoopGroup())
.channel(NioServerSocketChannel.class)
.childHandler(new WebSocketServerInitializerFactory());
Channel ch = bootstrap.bind(serverHost, port).sync().channel();
I use the above mentioned way (with serverHost as localhost and port = 80) and encounter the address already in use exception
java.net.BindException: Address already in use: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:344)
at sun.nio.ch.Net.bind(Net.java:336)
at
sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:199)
at
sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:98)
at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:646)
at io.netty.channel.DefaultChannelPipeline$HeadHandler.bind(DefaultChannelPipeline.java:1296)
at io.netty.channel.DefaultChannelHandlerContext.invokeBind0(DefaultChannelHandlerContext.java:1026)
at io.netty.channel.DefaultChannelHandlerContext.invokeBind(DefaultChannelHandlerContext.java:1012)
at io.netty.channel.DefaultChannelHandlerContext.bind(DefaultChannelHandlerContext.java:1006)
at io.netty.channel.DefaultChannelPipeline.bind(DefaultChannelPipeline.java:1072)
at io.netty.channel.AbstractChannel.bind(AbstractChannel.java:250)
at io.netty.bootstrap.AbstractBootstrap$2.run(AbstractBootstrap.java:332)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:328)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:331)
at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:109)
at java.lang.Thread.run(Thread.java:722)
Is there a way in which I can re-use port 80 that is already being used to serve http requests by Apache?
Thanks in advance.