Skip to content

Configuration details

Nikita Koksharov edited this page Aug 8, 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

  • setPreferDirectBuffer (added in 1.5 version) Buffer allocation method used during packet encoding

  • setBossExecutor (removed from 1.5 version) Sets the BossExecutor of underlying NioServer, defaults to Executors.newCachedThreadPool()

  • setWorkerExecutor (removed from 1.5 version) Sets the WorkerExecutor of underlying NioServer, defaults to Executors.newCachedThreadPool()

  • setBossThreads (added in 1.5 version) boss-threads amount for netty

  • setWorkerThreads (added in 1.5 version) worker-threads amount for netty

  • 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