Skip to content

Configuration details

Nikita Koksharov edited this page Jul 30, 2013 · 15 revisions

Netty-socketio Configuration details

Netty-socketio can be configured by means of a Configuration object provided during server creation. Such configuration is cloned, so further changes to the Configuration object will not affect server.

Details

  • setHostname If not set then bind address will be 0.0.0.0 or ::0
  • setPort The port the socket.io server will listen to
  • setJsonTypeFieldName defaults to "@class"
  • setJsonSupport Allows to setup custom implementation of JSON serialization/deserialization. See JsonSupport
  • setBossExecutor Sets the BossExecutor of underlying NioServer, defaults to Executors.newCachedThreadPool() (removed from 1.5)
  • setWorkerExecutor Sets the WorkerExecutor of underlying NioServer, defaults to Executors.newCachedThreadPool() (removed from 1.5)
  • setBossThreads boss-threads amount for netty (added in 1.5)
  • setWorkerThreads worker-threads amount for netty (added in 1.5)
  • setHeartbeatInterval Heartbeat interval (in seconds), defaults to 25
  • setHeartbeatTimeout Heartbeat timeout (in seconds), defaults to 60. Use 0 to disable it
  • setHeartbeatThreadPoolSize Heartbeat thread pool size, defaults to 2 times the "available processors" at runtime
  • setCloseTimeout Channel close timeout (in seconds) due to inactivity, defaults to 60
  • setContext Namespace, defaults to "/socket.io"
  • setAllowCustomRequests Allow to service custom requests that differ from socket.io protocol, defaults to false.
    • If true, add own handler which handle custom requests in order to avoid hang connections.
  • setPollingDuration Polling interval for XHR transport (in seconds), defaults to 20
  • setKeyStorePassword SSL key store password (for secure connections)
  • setKeyStore SSL key store stream, maybe appointed to any source
  • setMaxHttpContentLength Set maximum HTTP content length limit, defaults to 64KB.
    • If the length of the aggregated content exceeds this value, a TooLongFrameException will be raised.
  • setTransports Transports supported by server, defaults to [Transport.WEBSOCKET, Transport.FLASHSOCKET, Transport.XHRPOLLING]. Cannot be empty list

Usage example

    Configuration config = new Configuration();
    config.setHostname("localhost");
    config.setPort(1337);
    config.setCloseTimeout(30);
    
    SocketIOServer server = new SocketIOServer(config);
Clone this wiki locally