BlueBox and Websocket Connection

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

Moderators: Lapo, Bax

shashankpanwar
Posts: 6
Joined: 09 Apr 2021, 12:27

BlueBox and Websocket Connection

Postby shashankpanwar » 20 Jul 2021, 07:23

Hello SmartFoxTeam,
i wanted to know while using blue box for client communications when does the WebSocket gets created or it doesn't ?
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: BlueBox and Websocket Connection

Postby Lapo » 20 Jul 2021, 09:51

Hi,
the BlueBox is used as a backup connection system if a normal TCP connection is not possible for the client. For example because the client is behind a proxy or firewall blocking most uncommon traffic.

The BlueBox tunnels the connection via HTTP thus allowing most clients to be able to connect, as firewalls and proxies typically allow HTTP traffic. Also the BlueBox does not use Websocket, but rather an optimized HTTP polling system.
You can read more here:
http://docs2x.smartfoxserver.com/GettingStarted/bluebox

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
shashankpanwar
Posts: 6
Joined: 09 Apr 2021, 12:27

Re: BlueBox and Websocket Connection

Postby shashankpanwar » 20 Jul 2021, 11:16

Thanks, But our requirement is as follows ::
We don't want the WebSocket(9933) to be connected at first and want to add a custom filter to different requests on server side ,Is there a way of doing this ? We want to do this in case of DOS attacks.
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: BlueBox and Websocket Connection

Postby Lapo » 20 Jul 2021, 14:31

Let me clarify one aspect:
Websocket is not port 9933.

SmartFoxServer uses port TCP/UDP port 9933 for socket connections using the SFS2X protocol.
You can alternatively use the HTTP Websocket protocol (on port 8080 or 8443) for HTML5 or Unity WebGL clients.

With this said, sorry but I don't understand your question. I have no idea what kind of filters you're referring to.
Can you please explain what kind of client API you're using and what is your use case?

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
shashankpanwar
Posts: 6
Joined: 09 Apr 2021, 12:27

Re: BlueBox and Websocket Connection

Postby shashankpanwar » 21 Jul 2021, 09:05

Hello Lapo,
We want to put a custom API gateway on the server-side using JS API on the client-side on `first connection` using either the port 8080 or 8443. Whenever the first request comes from the web client(JS), we want the SFS to have a custom API filter to that request. Is there a way to achieve this?
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: BlueBox and Websocket Connection

Postby Lapo » 21 Jul 2021, 14:08

Hi,
maybe there's a bit of confusion on my part because of the terminology you are using.

Let me try to explain a bit how SmartFoxServer works. When a client opens a connection it is simply making an initial handshake to make sure that communication is possible. After the connection is done (which is notified by a client-side SFSEvent.CONNECTION event) the user is still not able to do much with the server.

In fact at this point the client can only send a valid LoginRequest, requiring to join on of the available Zones in the server. Each Zone represents a different application that is running in SFS2X.

If you want you can handle the LoginRequest on the server side with your own custom code, which I think is what you're referring to as "filter" in your previous post.
If that's the case you can read how this is done here:
https://smartfoxserver.com/blog/how-to- ... tom-login/

And if you're new to creating server side Extensions you should start from here:
http://docs2x.smartfoxserver.com/Extens ... uick-start

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
shashankpanwar
Posts: 6
Joined: 09 Apr 2021, 12:27

Re: BlueBox and Websocket Connection

Postby shashankpanwar » 27 Jul 2021, 15:54

Hello Lapo,
Thank you for your help, but we are still having some questions like
a) Can we use the Anti-flood filter on the `LoginRequest`? or
b) Use ISystemFilterChain `SystemRequest.Login` at the Zone extension ?

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

Re: BlueBox and Websocket Connection

Postby Lapo » 27 Jul 2021, 16:16

Hi,
no, there's no direct way to apply a Flood Filter to the Login request, but you can track those requests in your server side code.
No need to use a FilterChain. Just a normal Extension.

When a Session sends a LoginRequest you can store the current timestamp (System.currentTimeMillis) as a property of the Session itself and proceed by validating the request. If another request (from the same Session) is received later you can compare it with the previous timestamp and decide to drop it or not.

The methods I am referring to are Session.getProperty() and Session.setProperty()

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 40 guests