WS not working when WSS is enabled on Unity3d WebGL

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

Moderators: Lapo, Bax

Tatanan
Posts: 112
Joined: 07 Jan 2014, 12:12
Contact:

WS not working when WSS is enabled on Unity3d WebGL

Postby Tatanan » 07 Feb 2017, 15:25

Hi,

If I enable WSS protocol on Admin Tool, not secure websocket (WS) refuses the connection even when the Unity´s app is loaded on a http url (not https). If WSS is enabled it automatically disables WS?.

Here the Error messages:
- WebSocket connection to 'ws://www.example.com:8888/websocket' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
- Connection error: Abnormal disconnection.

Any idea?
Thanks
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: WS not working when WSS is enabled on Unity3d WebGL

Postby Lapo » 07 Feb 2017, 15:36

Yes, websockets can be run in encrypted or unencrypted mode, but not both at the same time.
Lapo
--
gotoAndPlay()
...addicted to flash games
Tatanan
Posts: 112
Joined: 07 Jan 2014, 12:12
Contact:

Re: WS not working when WSS is enabled on Unity3d WebGL

Postby Tatanan » 07 Feb 2017, 16:01

ok, thanks.

Another question:
Does using WSS or Protocol Cryptography have any a performance/bandwidth penalty or the performance is almost equal?
I see in the doc that Protocol Cryptography uses jetty under de hood, does it means the communication is manage by jetty
through http protocol like BlueBox instead of using sockets?

thanks.
Tatanan
Posts: 112
Joined: 07 Jan 2014, 12:12
Contact:

Re: WS not working when WSS is enabled on Unity3d WebGL

Postby Tatanan » 07 Feb 2017, 16:54

Hi,

One more question about Cryptography (maybe it deserve a new topic):

On admin tool -> zone configuration -> user encryption (i) says that "If turned on, the server will only accept encrypted connection; otherwise either connections are allowed"; but I if I call StartCoroutine (sfs.InitCrypto ()); the SFSEvent.CRYPTO_INIT event is success but when I try to login the connection is refused. Server log trace is "Login rejected. The requested Zone does not support encryption". (I user custom login). When I enable "Use encryption" then not-encryption connections are refused and encrypted connections login properly.

How can I do to make both systems co-exist.

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

Re: WS not working when WSS is enabled on Unity3d WebGL

Postby Lapo » 07 Feb 2017, 17:37

Tatanan wrote:ok, thanks.

Another question:
Does using WSS or Protocol Cryptography have any a performance/bandwidth penalty or the performance is almost equal?
I see in the doc that Protocol Cryptography uses jetty under de hood, does it means the communication is manage by jetty
through http protocol like BlueBox instead of using sockets?

There can be a little performance hit when using cryptography, of course, depending on the hardware in use. It may be more noticeable on older machines but in general it's nothing to worry about.

WSS Cryptography is not handled by Jetty in SmartFoxServer.
WSS is technically part of the HTTP protocol, but uses persistent connection and a full duplex channel, and no it's got nothing to do with the BlueBox, that's HTTP tunnelling.

cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: WS not working when WSS is enabled on Unity3d WebGL

Postby Lapo » 07 Feb 2017, 17:40

Tatanan wrote:On admin tool -> zone configuration -> user encryption (i) says that "If turned on, the server will only accept encrypted connection; otherwise either connections are allowed"; but I if I call StartCoroutine (sfs.InitCrypto ()); the SFSEvent.CRYPTO_INIT event is success but when I try to login the connection is refused. Server log trace is "Login rejected. The requested Zone does not support encryption". (I user custom login). When I enable "Use encryption" then not-encryption connections are refused and encrypted connections login properly.

How can I do to make both systems co-exist.


You're talking about a different subject here. SmartFoxServer can talk to clients with a number of different protocols:

1- native SFS2X protocol over TCP and UDP
2- websocket protocol over TCP
3- HTTP Tunnel (BlueBox)

You don't need to use SFS2X own cryptography if you're already using WSS. They are two separate things.

hope it's clear.
Lapo

--

gotoAndPlay()

...addicted to flash games
Tatanan
Posts: 112
Joined: 07 Jan 2014, 12:12
Contact:

Re: WS not working when WSS is enabled on Unity3d WebGL

Postby Tatanan » 07 Feb 2017, 18:04

Sorry I think I have mixed two different question: WSS and Native encrypted sockets .

Our games are Unity3D´s cross-platfom (WebGL and mobile) so, I want to enable encryption on every platform but I want to make co-exist encrypted and non-encrypted games. Because your first answer I know websockets can not be run together WS and WSS, but this is not a problem because the games are hosted on our website so we can deploy all of them at the same time and force users to download the newest version. The problem comes with mobile distributions, because either Google and Apple propagate new builds in a time window of hours, so in that time old builds (non encrypted) and new builds (encrypted) must be able to connect the SmartfoxServer.

So for Unity´s mobile games (Android and iOS) can I make a zone accept native encrypted and not-encrypted logins?

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

Re: WS not working when WSS is enabled on Unity3d WebGL

Postby Lapo » 08 Feb 2017, 08:12

Hi,
no not in the same Zone.
It would defeat the security of running an encrypted protocol. Malicious clients could simply hack the client, make it run with unencrypted protocol and then easily manipulate or forge messages. Not only that but they could see other player's relevant data, such as position, variables etc... (because some of this data is broadcast to all players to keep them in synch)

What you could do is having two Zones for different types of clients, encrypted and non encrypted.

So, to recap:
Websockets : the setting is global, you can either run WS or WSS in the whole server.
Native SFS2X: the setting is per-zone.

hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
Tatanan
Posts: 112
Joined: 07 Jan 2014, 12:12
Contact:

Re: WS not working when WSS is enabled on Unity3d WebGL

Postby Tatanan » 08 Feb 2017, 08:21

Thank for the info, it is very useful.

And here the last question about this topic, just to be sure :P

WSS and Non-Encrypted native sockets can life together, right? I mean, WebGL uses WSS (enabled on all the zones) meanwhile mobile platforms still use Non-Encrypted native sockets (zone encrypt switched off).

Thank.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: WS not working when WSS is enabled on Unity3d WebGL

Postby Lapo » 08 Feb 2017, 08:53

Tatanan wrote:Thank for the info, it is very useful.

And here the last question about this topic, just to be sure :P

WSS and Non-Encrypted native sockets can life together, right? I mean, WebGL uses WSS (enabled on all the zones) meanwhile mobile platforms still use Non-Encrypted native sockets (zone encrypt switched off).

Yes, this is fine.

cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: Stevenor and 107 guests