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: 308
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: 308
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: 1827
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: 308
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: 1827
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: 308
Joined: December 12th, 2012, 8:46 pm


Return to Scripting



cron