Forum Scripting Unity WebGL socket error, https

Post your problems and discussions relating to scripting in Unity here.

Unity WebGL socket error, https

Postby robscherer123 » April 10th, 2019, 9:51 pm

I'm testing my Unity game in WebGL to start getting some players to test it, however I'm having some security issues. I've narrowed it down to it only happening when the game is played from an https url. I have useSecureConnections set to true inside the PlayerIO class in Unity, which fixed one issue I was having. I believe this issue is coming from the join room call. The connect to service, and load bigDB calls are working fine (so far).

The error as reported from PlayerIOError in Unity is "General Error: Unable to connect, errorCode=SocketError".

The error output from the javascript console is "Mixed Content: The page at 'https://eliatopia.com/includes/testing/' was loaded over HTTPS, but attempted to connect to the insecure WebSocket endpoint 'ws://108.178.15.218/'. This request has been blocked; this endpoint must be available over WSS."

Does that mean it's a bug that must be changed inside the PlayerIO SDK? Or am I just missing a security setting or something somewhere?
robscherer123
Paid Member
 
Posts: 311
Joined: December 12th, 2012, 8:46 pm

Re: Unity WebGL socket error, https

Postby robscherer123 » April 15th, 2019, 5:26 pm

Just confirming, I've updated to the newest SDK and am still having this issue. =/
robscherer123
Paid Member
 
Posts: 311
Joined: December 12th, 2012, 8:46 pm

Re: Unity WebGL socket error, https

Postby Henrik » April 16th, 2019, 4:14 am

Hey,

What version of Unity are you using?

What device are you testing this WebGL build on? Desktop computer? Mobile device?

Where in your code are you setting useSecureConnections to true?

The thing that sticks out to me is that you're getting a websocket address with an ip address and not a hostname. If useSecureConnections was properly set to true and the unity platform runtime is webgl, then it should want to connect to a websocket address with a hostname, i.e. wss://gs48.playerio.com/ in your case.
Henrik
.IO
 
Posts: 1853
Joined: January 4th, 2010, 1:53 pm

Re: Unity WebGL socket error, https

Postby robscherer123 » April 16th, 2019, 4:11 pm

I've tried with Unity version 2018.3.12f1, and now I've also tried with version 2019.1.0f2.

I'm testing on a Windows desktop on Google Chrome, also tried on Firefox.

I set useSecureConnections to true right before I call authenticate, so it's on the line directly before calling Authenticate.

Just tested again, and to be triple sure I called Debug.Log(PlayerIO.UseSecureApiRequests) inside the room join failed method. It printed true in the javascript console, so UseSecureApiRequests is for sure true whenever it fails.

If it is of any use, here is a test URL: https://helmetgames.com/test/ You can also change it to http instead of https, to see that it works over http. Just click "Play As Guest" for a quick test.
robscherer123
Paid Member
 
Posts: 311
Joined: December 12th, 2012, 8:46 pm

Re: Unity WebGL socket error, https

Postby Henrik » April 17th, 2019, 6:27 am

robscherer123 wrote:I set useSecureConnections to true right before I call authenticate, so it's on the line directly before calling Authenticate.

Just tested again, and to be triple sure I called Debug.Log(PlayerIO.UseSecureApiRequests) inside the room join failed method. It printed true in the javascript console, so UseSecureApiRequests is for sure true whenever it fails.

There's two properties, and you're confusing them. :-P

https://playerio.com/documentation/refe ... piRequests is the one you set on the PlayerIO object, and it applies to all API requests that you make, such as Authenticate, and makes them go over HTTPS instead of HTTP.

https://playerio.com/documentation/refe ... onnections is a property on Multiplayer on an authenticated client, and it applies to all multiplayer connections, and makes them go over SSL (for most environments) or secure WebSockets (for WebGL and JS environments)
Henrik
.IO
 
Posts: 1853
Joined: January 4th, 2010, 1:53 pm

Re: Unity WebGL socket error, https

Postby robscherer123 » April 17th, 2019, 1:34 pm

Ooooh, wow ok makes sense. I didn't realize there were two separate ones. Awesome, it's an easy fix then. Thanks for the help!
robscherer123
Paid Member
 
Posts: 311
Joined: December 12th, 2012, 8:46 pm

Re: Unity WebGL socket error, https

Postby wbsaputra » July 30th, 2020, 9:11 am

I had same issue, how do you solve?
I had set both to true, but still has problem

Firefox can’t establish a connection to the server at wss://gs2.playerio.com/. 005f011f-cff0-9540-86d3-1f2fe25414c9 line 2 > eval:75:49
Firefox can’t establish a connection to the server at wss://gs2.playerio.com:911/. 005f011f-cff0-9540-86d3-1f2fe25414c9 line 2 > eval:75:49
Firefox can’t establish a connection to the server at wss://gs2.playerio.com:1200/. 005f011f-cff0-9540-86d3-1f2fe25414c9 line 2 > eval:75:49
Firefox can’t establish a connection to the server at wss://gs2.playerio.com:4505/. 005f011f-cff0-9540-86d3-1f2fe25414c9 line 2 > eval:75:49
Firefox can’t establish a connection to the server at wss://gs2.playerio.com:8184/. 005f011f-cff0-9540-86d3-1f2fe25414c9 line 2 > eval:75:49
Firefox can’t establish a connection to the server at wss://gs2.playerio.com:27000/. 005f011f-cff0-9540-86d3-1f2fe25414c9 line 2 > eval:75:49
Failed connect to service GeneralError; Unable to connect, errorcode=SocketError 2 UnityLoader.js:3:41615
wbsaputra
Paid Member
 
Posts: 144
Joined: June 29th, 2010, 4:38 pm

Re: Unity WebGL socket error, https

Postby Henrik » August 1st, 2020, 12:54 pm

Wow, that's a really unhelpful error message. Thanks, Firefox. :-/

Can you try the same thing, but in your CreateJoinRoom, add a roomdata argument:

Code: Select all
"Cluster", "Player.IO Main Cluster"

That will force your game to connect to a different gameserver that is running with a different HTTPS certificate. I suspect that this might be why you're getting this error message. You will know that the roomdata argument worked if you can see it connecting to a different server than gs2.playerio.com
Henrik
.IO
 
Posts: 1853
Joined: January 4th, 2010, 1:53 pm

Re: Unity WebGL socket error, https

Postby Henrik » August 1st, 2020, 12:54 pm

You can also try running your WebGL game in Chrome instead of Firefox, that way you might get a more helpful message telling you why it can't connect to that gameserver.
Henrik
.IO
 
Posts: 1853
Joined: January 4th, 2010, 1:53 pm

Re: Unity WebGL socket error, https

Postby wbsaputra » August 1st, 2020, 3:43 pm

Hi Henrik, thanks for reply.

I'm trying to connect to SERVICE room on unity webgl build with Facebook quick connect.
Last try I've created new game id on both Facebook and PlayerIO for test purpose.
then setup Facebook setting to this new gameId and try reconnect with the same code, and holla it succesfully connected.
but when i switch back to first game is the errors happened again.
I will try your suggestion and come back later with result.
I have tried with chrome, safari and firefox, all with same result, in chrome I just got general socket error message.
wbsaputra
Paid Member
 
Posts: 144
Joined: June 29th, 2010, 4:38 pm

Re: Unity WebGL socket error, https

Postby Henrik » August 4th, 2020, 11:09 am

In your test game I see you have the Player.IO Main Cluster before your private cluster. If you switch the order, does your test game still work?
Henrik
.IO
 
Posts: 1853
Joined: January 4th, 2010, 1:53 pm

Re: Unity WebGL socket error, https

Postby wbsaputra » August 5th, 2020, 11:13 am

Yes, it work now, I'm not imagined that will cause the issue, thanks
wbsaputra
Paid Member
 
Posts: 144
Joined: June 29th, 2010, 4:38 pm

Re: Unity WebGL socket error, https

Postby Henrik » Yesterday, 3:34 am

Thanks for helping me trouble-shoot. I've upgraded your private cluster to the latest version so that everything will work on that as well.
Henrik
.IO
 
Posts: 1853
Joined: January 4th, 2010, 1:53 pm

Re: Unity WebGL socket error, https

Postby wbsaputra » Yesterday, 1:21 pm

Btw Henrik, do you have sample or link for PayVault Facebook WebGL for Unity?
The documentation only for AS3
wbsaputra
Paid Member
 
Posts: 144
Joined: June 29th, 2010, 4:38 pm


Return to Scripting



cron