Spring Boot

netty-socket-io.hostname=localhost
netty-socket-io.port=9092
netty-socket-io.ping-timeout=60000
netty-socket-io.ping-interval=25000

Just adding the properties/yml is enough to run the server with default settings. If you want to add SocketIOServer bean exclude the default server

Custom SocketIOServer Bean

@Configuration
public class SocketIOConfig {
    
    @Bean
    public SocketIOServer socketIOServer() {
        Configuration config = new Configuration();
        config.setHostname("localhost");
        config.setPort(9092);
        return new SocketIOServer(config);
    }
}

Main Application

Event Handler with Annotations

You can use annotations to define event handlers:

Exception Handling

Full Example

See the complete example in the netty-socketio-examples-spring-boot-base module.

Last updated

Was this helpful?