SFS2X Docs / GettingStarted / migration-213
» Websocket migration, release 2.13+
A number of different things have changed for websockets with the release of SmartFoxServer 2.13:
- Websocket ports
- Websocket protocol
- HTML5 / JavaScript API implementing standard SFS2X binary protocol
- Unity WebGL / C# API implementing standard SFS2X binary protocol
Please make sure to follow this brief guide if you have a websocket-based project (JavaScript or Unity WebGL) running on previous versions of SmartFoxServer 2X.
» Websocket ports
Starting from v2.13, SmartFoxServer uses the Jetty Web Server to run all HTTP-related services, including websockets. This means that you no longer have to setup different TCP ports for HTTP/HTTPS services and WS/WSS services. Instead all services now run on two main TCP ports, which by default are:
- HTTP / WS / BlueBox = 8080
- HTTPS / WSS = 8443
If you want to change these ports you can do so via the AdminTool > Server Settings > Web Server tab.
Please note: out of the box, the websocket services are not active. You can turn them on via the "Enable WS/WSS" switch shown in the image above, choose the type of protocol (default = binary; read below) and restart the server.
» Client API and protocol
Before release v2.13, the JavaScript and C# (Unity WebGL only!) APIs used a JSON-based protocol for websocket communication. With SFS2X 2.13 and later we offer new, improved APIs which use the efficient SFS2X binary/compressed protocol that is implemented in all other supported languages.
By default the server uses the new protocol but you can still revert to the previous version by switching off the "Use WS binary protocol" option from the picture above.
For all new HTML5 / Unity WebGL projects we highly recommend to start working with the new binary protocol API as this is more compact and efficient. Also this is the API we will focus on for the incoming future.
For older projects based on the previous API we will keep maintaining the code in terms of bug fixes, but we won't add any new features. With time we would encourage previous projects to migrate, if possible, to the new API.
ยป Compatibility notes for older projects
If you're going to upgrade to SFS2X v2.13 or later and run a websocket project developed with v2.12 or previous (in other words with the older JavaScript or C# API), we recommend to follow these simple steps:
- Install SFS2X v2.13 or later
- Run the AdminTool > Server Settings > Web server and change the following:
- Turn on "Enable WS/WSS"
- Turn off "Use WS binary protocol"
- If your application runs with WSS you will need to make sure that the SSL certificate is properly deployed in Jetty; you can follow these instructions to do so
- Restart SFS2X
- Change your client's WS/WSS ports to the new values used in SFS2X v2.13
- Double check your firewall configuration to make sure the WS/WSS traffic is allowed on the new ports
- Done!
If you have any questions or problems with websocket settings you can reach us through our support forum.