Listening to multiple TCP and Websocket Ports at once

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Muxa
Posts: 6
Joined: 23 Jun 2021, 04:54

Listening to multiple TCP and Websocket Ports at once

Postby Muxa » 23 Jun 2021, 05:01

Hello,

We are highly interested in purchasing 3 licenses for SFS.
We have the follow purchase questions please:-

1) is it possible for the server (TCP, Websocket) listen to multiple ports at once

For example we want SFS server TCP listener to accept incoming connections to ports ( 5060,5050,9090,4444) all at the same time and treat the income connections as normal one ports listener.
* same for websocket WSS multiple ports too now only one at config

Is that achievable with sfs2 server ? Currently we are doing so with our custom tcp websocket server using .net

2) is it possible to use sfs2 server as reverseed proxy and forward incoming traffic only ( we are using reversed proxy forwarding feature to prevent direct API calls to our backends .

Thanks
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Listening to multiple TCP and Websocket Ports at once

Postby Lapo » 23 Jun 2021, 07:19

Hello,
using the default SFS2X TCP protocol you can bind multiple ports, so yes it is possible. (Though it's not possible for UDP)
However for Websocket it's a bit of a different story. All HTTP-related services in SFS2X are handled by an embedded Tomcat instance.

Tomcat can be configured to run on multiple ports, but:
1) we have never tested it with such setup (I think it should work because it already runs on two ports, HTTP and HTTPS)
2) I suspect it will cause a larger use of resources, because every added connector (a.k.a port listener) starts its own thread pool so it can get a bit expensive if you need many active connectors.

Also generally speaking having so many active ports for connections is going to complicate things in terms of managing firewalls and instructing clients on which ports are available and should be used.

Is there a specific reason for this?
2) is it possible to use sfs2 server as reverseed proxy and forward incoming traffic only ( we are using reversed proxy forwarding feature to prevent direct API calls to our backends .

It depends if you're speaking in a strict way or not. Strictly speaking a proxy server (including the reverse variant) is a server that acts transparently on behalf of a client to fetch certain resources.

And strictly speaking, SFS2X is a multiplayer TCP/UDP server, so a completely different kind of application server.

As regards not exposing the backend, SFS2X can act as a front facing server that talks to your backend, (be it a database or HTTP services etc...), processes the data and sends a response back to the client. So in a way it can be thought of a kind of proxy but in reality it really isn't one.

It's the same scenario as a front facing Apache server accessing data from a private MySQL DB and then sending the processed data back to the client.

Hope it's clear.
Lapo
--
gotoAndPlay()
...addicted to flash games
Muxa
Posts: 6
Joined: 23 Jun 2021, 04:54

Re: Listening to multiple TCP and Websocket Ports at once

Postby Muxa » 28 Jun 2021, 07:52

Hello Lapo,

Thank you so much for the detailed response .

Regarding multiple ports , we use this technique to retry list of ports array in case user couldn't connect through the default port and at our region its important for our game ... at sfs I know that the fail over mechanism is great and the fail over to http port will occur if connection wasn't successful ex: behind firewall..

We have the following scenario at our game and in order to switch to smartfoxserver we have to solve few concerns please.

We built our game server 9 years ago using TCP connectivity , then when flash deprecated
We had to implement WSS forwarding proxy to forward all incoming websocket traffic to our tcp server instant . By doing so we did not modify the original tcp server code and simply introduced WebSocket forwarding server.

We need implement the power of sfs to replace current WebSocket server , as start no game logic will be handled by sfs simply connecting forwarding and replying..

We did lots of research and compared aws , playfab with sfs etc.. , we trust that sfs will give us more control and flexibility to scale our game and provide more options at the future.

As a start we want to only utilizing sfs connection module and analytics first this should happen before rewriting the game logic within SFS as its time consuming and we will face bugs during the development process that we don't have time to solve as our game users number growing ...

Please if you can share your professional advice for the follow scenarios :-

1) Current game setup

WebSocket listener forwarding to tcp
Ports [5060, 4444,8080,80] ---> forward --> tcp game server port [1370]

Html5 clients can connect and play the game, game logic at TCP server

2) sfs websocket listener, tcp listener---> forward incoming connections to our tcp server and maintain the active connections
We will develop sfs Java extension for that

We don't want to use authentication module, db module as a start only connection module.

Thanks
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Listening to multiple TCP and Websocket Ports at once

Postby Lapo » 28 Jun 2021, 15:40

Hi,
I am not sure if understand this completely.

We built our game server 9 years ago using TCP connectivity , then when flash deprecated
We had to implement WSS forwarding proxy to forward all incoming websocket traffic to our tcp server instant . By doing so we did not modify the original tcp server code and simply introduced WebSocket forwarding server.

So the game you created 9 years ago, was not based on SmartFoxServer, but rather your own TCP server. Is this correct?

We need implement the power of sfs to replace current WebSocket server , as start no game logic will be handled by sfs simply connecting forwarding and replying..

I am not sure that this will work.
SmartFoxServer wraps its own native protocol in Websocket packets, so it can be used as a proxy, because it must receive data that speaks the SFS protocol and from what I understand your game client does not speak the SFS2X protocol. Can you clarify this point?

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 40 guests