SFS2X Docs / GettingStarted / bluebox
» The BlueBox 2X
The BlueBox is an HTTP tunneling technology that allows clients to connect from behind firewalls and proxies, when a socket connection is not available. This is a typical scenario for corporate offices, schools and other institutions where the network traffic is limited to a few selected services.
The BlueBox enables players under restricted network configurations to play and enjoy fast multiplayer apps and games with minor performance loss. All SmartFoxServer clients based on TCP sockets can take advantage of the BlueBox without any code change.
Behind the scenes the BlueBox uses an HTTP tunnel by wrapping the SmartFoxServer protocol into HTTP requests, which in turn allows to pass through firewalls and most proxies.
Additionally the BlueBox uses asynchronous processing to reduce the need for continuous polling, improving overall performance and reducing latency when compared to standard polling-based solutions. Finally the client API provide the developer with the ability to fine tune the server response times, allowing near real-time performance.
» How to use the BlueBox
The BlueBox service depends on the HTTP server provided with SmartFoxServer 2X, which is active by default and therefore there's no extra step required to have this feature ready to work. As soon as the server is running any client will be able to connect both via the default TCP port (9933) or BlueBox (port 8080).
The only requried settings are located on the client side, in the external client config file or via the equivalent ConfigData object.
<SmartFoxConfig> <!-- Mandatory Settings --> <ip>192.168.0.16</ip> <port>9932</port> <zone>Test</zone> <!-- End Mandatory Settings --> <debug>true</debug> <httpPort>8080</httpPort> <useBlueBox>true</useBlueBox> <blueBoxPollingRate>500</blueBoxPollingRate> </SmartFoxConfig>
The last three settings in the XML above are specific to the BlueBox:
- httpPort: indicates the port of the internal web server;
- useBlueBox: toggles the option to connect to the BlueBox if sockets are not available;
- blueBoxPollingRate: controls the pause between multiple ping requests; the default value is already ideal for 99% of the situations, while for fast real-time action you can experiment with smaller values (250-300). We don't really recommend to use values below 150ms.
» Recommended settings
By default SFS2X uses the following ports:
- TCP 9933 for socket traffic
- TCP 8080 for HTTP traffic
If you are under Unix/Linux/MacOSX this will require that the server runs with root privileges.
NOTE: The BlueBox failover mechanism applies only for TCP based clients. Websocket clients are not supported.
» Security
When the protocol cryptography is activated, the BlueBox traffic gets automatically encrypted as well, even when running on the default HTTP port. While it is possible to run the tunneled connection via HTTPS (by pointing the BlueBox client to SFS2X's HTTPS port) it's actually not necessary.» Monitoring the BlueBox
The connections handled by the BlueBox maintain a special session used by the enclosing HTTP protocol. You can monitor these sessions from the AdminTool by launching the BlueBox Monitor module.
Finally the BlueBox process logs specific usage data under the SFS2X/logs/http/ folder.