I deployed my Spring Boot Socket.IO application to Azure Web App for Containers.
In Docker, I am using port 80 for Spring and port 443 for Socket.IO.
I have tried using the Azure Virtual IP address and default domain values for the hostname, but I keep getting the following error:
Caused by: java.net.BindException: Cannot assign requested address
2023-07-15T15:49:58.391590007Z at java.base/sun.nio.ch.Net.bind0(Native Method) ~[na:na]
2023-07-15T15:49:58.391594407Z at java.base/sun.nio.ch.Net.bind(Net.java:555) ~[na:na]
2023-07-15T15:49:58.391598807Z at java.base/sun.nio.ch.ServerSocketChannelImpl.netBind(ServerSocketChannelImpl.java:337) ~[na:na]
2023-07-15T15:49:58.391606707Z at java.base/sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:294) ~[na:na]
2023-07-15T15:49:58.391614307Z at io.netty.channel.socket.nio.NioServerSocketChannel.doBind(NioServerSocketChannel.java:141) ~[netty-transport-4.1.94.Final.jar!/:4.1.94.Final]
2023-07-15T15:49:58.391618807Z at io.netty.channel.AbstractChannel$AbstractUnsafe.bind(AbstractChannel.java:562) ~[netty-transport-4.1.94.Final.jar!/:4.1.94.Final]
2023-07-15T15:49:58.391623407Z at io.netty.channel.DefaultChannelPipeline$HeadContext.bind(DefaultChannelPipeline.java:1334) ~[netty-transport-4.1.94.Final.jar!/:4.1.94.Final]
2023-07-15T15:49:58.391627908Z at io.netty.channel.AbstractChannelHandlerContext.invokeBind(AbstractChannelHandlerContext.java:600) ~[netty-transport-4.1.94.Final.jar!/:4.1.94.Final]
Mostly, the above error occurs when the port that you are trying to bind is already in use. Bind the
Socket.IOserver to a different port that doesn't conflict with the default ports used by Azure Web App for Containers.Socket.IO.I used java 11 version for the application(springboot).
Dependencies:
In Docker container:
ChatApplication:
Then, I created a webapp that gets deployed from ACR and configures the Ports:
Container Logs: