Skip to main content

Server Setup

Detailed guide for configuring and customizing your Sproogy socket server.

Server Configuration

@Component
public class MyServerFactory implements ServerFactory {

@Autowired
private SSLFactoryLoader sslLoader;

@Override
public Server createServer() {
return new DefaultServer(
sslLoader,
Integer.parseInt(EnvLoader.get("SOCKET_PORT")),
requestFormatProperty,
responseFormatProperty
);
}
}

Thread Pool Tuning

Configure the server's thread pool for optimal performance:

ExecutorService executor = Executors.newFixedThreadPool(
Runtime.getRuntime().availableProcessors() * 2
);

Graceful Shutdown

Sproogy automatically registers a shutdown hook:

Runtime.getRuntime().addShutdownHook(new Thread(() -> {
server.stopServer();
}));

Next Steps

👉 Hello World Socket - Complete example 👉 Filters - Add request interceptors 👉 SSL Configuration - Production SSL setup