[SOLVED] WebSocket Connection Error

Post here your questions about the HTML5 / JavaScript for SFS2X

Moderators: Lapo, Bax

User avatar
pogsdbest
Posts: 17
Joined: 08 Feb 2019, 10:09

[SOLVED] WebSocket Connection Error

Postby pogsdbest » 21 Feb 2019, 04:53

Hi guys im having an Error Connecting using My webgl build in unity

Code: Select all

port = 8443;
sfs = new SmartFox(UseWebSocket.WSS_BIN);

ConfigData cfg = new ConfigData ();
cfg.Host = serverHost;
cfg.Port = port;
cfg.Zone = defaultZone;
sfs.Connect ( cfg );


WebSocket connection to 'wss://myip/websocket' failed: Error in connection establishment: net::ERR_CERT_AUTHORITY_INVALID


on my Machine it connects, but when i send the link of my webgl build to others they get this error, is there anyone here encounter this before.
im using cloudflare.
Last edited by pogsdbest on 26 Feb 2019, 09:06, edited 1 time in total.
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: WebSocket Connection Error

Postby Lapo » 21 Feb 2019, 08:02

Hi,
you're using port 8443, which is dedicated to WSS (secure websocket).
In order to use WSS you must have a domain and valid SSL certificate, which is not possible for local testing.

I recommend simply using port 8080 instead, which is the standard for non encrypted websockets.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
pogsdbest
Posts: 17
Joined: 08 Feb 2019, 10:09

Re: WebSocket Connection Error

Postby pogsdbest » 22 Feb 2019, 06:17

thanks lapo, but we already have a domain and a valid certificate from cloudflare. and on our testing it is already working but only on my machine. when someone try to visit the webGL build that i uploaded to our domain. it gives me the said error


Capture.PNG
ErrorTrace
(32.62 KiB) Not downloaded yet

Capture.PNG
validCert
(13.08 KiB) Not downloaded yet
User avatar
Bax
Site Admin
Posts: 4609
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Re: WebSocket Connection Error

Postby Bax » 22 Feb 2019, 09:26

We noticed that the connection url uses the unusual "blob" system. Is there a reason for that? Could it be interfering with the certificate?
I suggest to test with a plain url.
Paolo Bax
The SmartFoxServer Team
User avatar
pogsdbest
Posts: 17
Joined: 08 Feb 2019, 10:09

Re: WebSocket Connection Error

Postby pogsdbest » 26 Feb 2019, 07:41

Hi Bax i tried the plain Url but still get the error

Image

error 1015.png
(25.09 KiB) Not downloaded yet
Last edited by pogsdbest on 26 Feb 2019, 08:00, edited 1 time in total.
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: WebSocket Connection Error

Postby Lapo » 26 Feb 2019, 07:57

If you're running a valid SSL certificate you must connect to your server via it's domain name, instead of it's IP address.
This is because the SSL certificate only works with domains, hence the SSL validation error.

Hope it helps
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
pogsdbest
Posts: 17
Joined: 08 Feb 2019, 10:09

Re: WebSocket Connection Error

Postby pogsdbest » 26 Feb 2019, 09:05

thanks guys, thanks lapo, its now working, :D :D :D :D
moonlife
Posts: 45
Joined: 26 Sep 2016, 08:22

Re: [SOLVED] WebSocket Connection Error

Postby moonlife » 29 Jan 2021, 14:07

Hi Lapo, I have same problem,

I cannot login to smartfoxserver on websocket with ssl.

I've also tried with sample project called "AdvancedConnector".

I've valid ssl and websocket property is open on my admin tool.

What should I do?

I can send you message the URL
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: [SOLVED] WebSocket Connection Error

Postby Lapo » 29 Jan 2021, 14:47

HI,
sure you can send the URL in a private message.
However we also need to know what client API you're using (and what version) and what errors are you getting both on client and server sides when the connection fails.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
moonlife
Posts: 45
Joined: 26 Sep 2016, 08:22

Re: [SOLVED] WebSocket Connection Error

Postby moonlife » 29 Jan 2021, 15:46

Hi,

I've sent a message to you. I use unity3d 2019.4.12f

it gives error like this

I've tried both with ip address and domain name

WebSocket connection to 'wss://ipadres:8443/websocket' failed: Error in connection establishment: net::ERR_CERT_AUTHORITY_INVALID

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

Re: [SOLVED] WebSocket Connection Error

Postby Lapo » 29 Jan 2021, 16:31

Hi,
you can't use the IP address with SSL, because the certificate is tied to your domain name, not the IP address.
You must use the domain name when connecting from client side.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games
moonlife
Posts: 45
Joined: 26 Sep 2016, 08:22

Re: [SOLVED] WebSocket Connection Error

Postby moonlife » 29 Jan 2021, 16:43

Hi,

I've also tried with domain name, but it given same error. You can try with domain that I've sent you in private message
moonlife
Posts: 45
Joined: 26 Sep 2016, 08:22

Re: [SOLVED] WebSocket Connection Error

Postby moonlife » 29 Jan 2021, 19:33

Hi Lapo, anything you suggest?
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: [SOLVED] WebSocket Connection Error

Postby Lapo » 30 Jan 2021, 16:01

Hi,
I just checked your domain in the browser on port 8443, which is the default for SFS2X and the page shows an SSL error, saying that there is no valid SSL certificate deployed.

That is the problem for sure :)

You have to deploy the a valid SSL certificate in SFS2, as per the docs here:
http://docs2x.smartfoxserver.com/Gettin ... yptography

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X HTML5 / JavaScript API”

Who is online

Users browsing this forum: No registered users and 20 guests