Category Archives: Articles

SmartFoxServer Roadmap!

With the new year (2024) we have started working on a set of major new features and improvements that will come to SmartFoxServer in due time. Here is a short list of what’s cooking:

  • Support for Java 21: the latest LTS release introduces new language features, powerful API and a new Garbage Collector that can be beneficial for server apps such as SmartFoxServer.
  • Virtual Threads: is one of the main attractions in JDK 21 and a long awaited feature to improve scalability. We’re planning to redesign the threading model in SmartFoxServer to take full advantage of this feature, simplify the the configuration and offer better performance overall.
  • Reliable UDP: a new addition to the SmartFoxServer bag of supported protocols. Reliable UDP (RDP in short) is ideal for low latency, real-time communication and we plan to provide multiple QoS (quality of service) levels to support different use cases.
  • Analytics Update: we’re also planning to redesign some of features of our Analytics module to make it more flexible and well integrated.
  • New Javascript runtime: since Nashorn was dropped in JDK 15 we’re researching different solutions to keep the support for Javascript on the Server side.
  • Lots more in R&D stage: there are at least another 3-4 major features that are in the early stages of research and a long list of other improvements and tweaks that will interest the server core and API.

At the moment there is no set release date as we’re in the building and testing phase, but we’ll publish more info when it’s time and provide more details.

Run SmartFoxServer 2X with JRE 16 and higher

As of 2023 SmartFoxServer 2X ships with the JRE 11 (LTS) out of the box, but it can also run with a higher version if needed.

In our documentation we have a detailed table with all the supported Java releases and their level of compatibility with SFS2X, which we recommend to consult.

At the time of writing this article SFS2X does not run with a JRE version 16 or higher without additional configuration. In this short article we will discuss how to configure the SmartFoxServer launchers to support the most recent Java runtimes, up to the latest JRE 20.

Continue reading

New in 2.19: Extension Flood Filter

With the release of SmartFoxServer 2.19.0 we have introduced a new Extension Flood Filter that provides fine grained control over the packet rate of Extension requests: it can be used to limit the number of calls per second for specific requests and automatically set rules for warning and banning the offending client(s).

It also includes the ability to catch unknown Extension calls (i.e. requests for which there doesn’t exist a request handler) and apply auto-ban rules as well.

Under normal circumstances, e.g. users playing with the official client app, there shouldn’t be a concern about request spam: limitations can be easily coded in the client itself. However it’s also relatively easy for malicious users to reverse engineer a client made in Javascript, Unity or Java and bypass such limitations.

Overview

In the diagram below we show a bird’s eye view of the filter and its position in the Extension invocation chain. For each request handler defined in our Extension code (via the addRequestHandler methods) we can set a limit expressed in number of calls per second.

Extension Flood Filter

In this example we have defined a playerShoot request handler and we’ve also set a limit of 4 requests/sec. If a client sends 20 calls in one second only the first 4 will be passed to the Extension and processed, while the rest will be discarded. Additionally, based on the auto-ban rules, the sender will either be warned or banned.

Usage

The Extension Flood Filter is inactive by default. To activate it we need to call the initFloodFilter(…) method available from the parent SFSExtension class.

public class AntiFloodTestExtension extends SFSExtension
{
    static final String PLAYER_SHOOT = "pShoot";
    static final String PLAYER_MOVE = "pMove";
 
    @Override
    public void init()
    {
        ExtensionFloodFilterConfig cfg = new ExtensionFloodFilterConfig();
        cfg.banDurationMinutes = 120;
        cfg.maxFloodingAttempts = 3;
        cfg.secondsBeforeBan = 2;
        cfg.banMessage = "You are now banned. Reason: request flooding.";
        cfg.filterRules = Map.of
                        (
                            PLAYER_SHOOT, 4, 
                            PLAYER_MOVE, 15
                        );
     
        initFloodFilter(cfg);
     
        addRequestHandler(PLAYER_SHOOT, (sender, param) -> {
         
            trace("Shooting");
     
        });
     
        addRequestHandler(PLAYER_MOVE, (sender, param) -> {
         
            trace("Moving");
     
        });
    }
}

The initializer method takes a ExtensionFloodFilterConfig object with with a number of properties for warning and banning clients.

For more details on each setting, default values and further details please check our documentation website here.

Custom Room Storage with SFS2X 2.18

Since the release of SmartFoxServer 2.18 we have introduced a way to override the default implementations for the Room Persistence API so that they can be customized to your needs.

Prior to this release we provided a file-based and a relational database-based storage mechanisms that could be used in conjunction with the API to save the state of multiple active Rooms.

With the new release you can now create your own storage implementations and plug them into the Persistence API. In this short article we’ll walk you through what has changed and how you can create a custom storage class.

Continue reading

SFS2X memory settings and garbage collection (part 2)

In our previous chapter we have talked about the JVM memory configuration: when to use the defaults and when it might be necessary to fine tune the settings. We also touched on potential side effects of manual tuning and how it can sometimes backfire, for example, forcing the Garbage Collector (GC) to work harder.

In the second part of this series we are taking a look at the different Garbage Collectors available, which is the best for a specific use case, and when it’s useful to switch to a different implementation.

Continue reading

Using a database in Overcast (part 3)

In the third (and last) part of this series we are taking a look at using the JDBC API to access a database via SFS2X Extensions. While this approach takes a bit more coding compared to the DBManager API (which we have explored in part 2) it also provides more sophisticated features such as working with metadata and advanced data types.

Continue reading

Using a database in Overcast (part 2)

In the previous installment of the this tutorial we have learned all the steps to create a database server in Overcast and connect to it from an existing SFS2X instance.

In this new chapter we are going to explore the database API that can be used to query the database from server side, using SFS2X Extensions.

If you are new to server side coding we highly recommend to get started with this article from our documentation, before proceeding with the rest of the tutorial.

Continue reading

SFS2X memory settings and garbage collection (part 1)

When running SmartFoxServer on machines with large amounts of RAM (e.g. 32/64GB or more) developers often have questions about strategies to make use of all resources, and how to optimize garbage collection.

At first these questions can seem intimidating, considering the vast amount of custom settings available for the Java Runtime and the multiple garbage collection options, each with its own set of configuration choices.

The good news is that navigating the complexity of the JVM is easier and less intimidating than expected (at least for SFS2X devs) and with this article we hope to simplify most SmartFoxServer users’ life.

Continue reading

Using a database in Overcast (part 1)

In this new article in the series dedicated to Overcast, the cloud solution for SmartFoxServer 2X, we will describe how to use a database server alongside SmartFoxServer.

In this first part of the article we will focus on launching the database, populating it with some test data and configuring SmartFoxServer to connect to it. In the second and third parts we will deploy an Extension in SmartFoxServer to test the connection with a query.

Continue reading