SFS2X Docs / GettingStarted / bluebox
» The BlueBox 2X
The BlueBox is an HTTP-based technology that allow 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 little to no noticeable performance loss. All SmartFoxServer applications can take advantage of the BlueBox without any code change.
Behind the scenes the BlueBox uses a so-called HTTP tunnel by wrapping the SmartFoxServer protocol into HTTP packets. The behavior of the BlueBox is pretty different from regular HTTP-polling solutions. The major disadvantages of a regular polling is the continuous traffic of requests coming from the clients, even during inactivity. Additionally the overall performance isn't very good especially if the polling interval is bigger than a couple of seconds.
The BlueBox uses a more sophisticated approach that eliminates the need for continuous polling. Additionally the client API provide the developer with the ability to fine tune the server response times, allowing near real-time performance!
» What's new in BlueBox 2X
The BlueBox 2X code was largely rewritten to provide a tighter integration with the new SFS2X engine (codename BitSwarm). Although the BlueBox 2X features are very similar to its predecessor, its architecture is much lighter and the performance increase is significantly improved.
The main difference in SFS2X is that the BlueBox plugs into the server engine directly, without the need to emulate a socket connection for each client (as in SFS 1.x). This in turn saves lots of resources and allows for better scalability of HTTP connections.
Starting from SFS2X RC2 the BlueBox is active by default in the server and doesn't require any particular setup. At any time a client that fails to establish a socket connection can attempt to use the BlueBox.
The only settings you need are located on the client side, in the external client config file.
<SmartFoxConfig> <!-- Mandatory Settings --> <ip>192.168.0.16</ip> <port>9932</port> <zone>Bench</zone> <!-- End Mandatory Settings --> <debug>true</debug> <httpPort>8080</httpPort> <useBlueBox>true</useBlueBox> <blueBoxPollingRate>500</blueBoxPollingRate> </SmartFoxConfig>
The last three settings that you see are specific for the BlueBox:
- httpPort: indicates the the port of the Jetty webserver;
- 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.
» 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.
Additionally the BlueBox process logs specific usage data under the SFS2X/logs/bluebox/ folder.