question

info-22 avatar image
info-22 asked

PlayFab / Mirror / Unity - Webgl Websockets

Hello,
I was following this game example https://github.com/natepac/playfabmirrorgameexample
everything works perfeclty on PC builds and in editor, but it fails on WebGL builds with the following error:

WebSocket connection to 'wss://52.149.252.147:7777/' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT
I later realized I wasn't adding the websocket transport so I added it and realized it asked for a certificate path and password.

I didn't add any certificates and uploaded a new server build to playfab and generated a new WebGL build but I got the same error, so after reading about certificates I realized I needed to know the IP of my server in order to create one, but my server build's IP is changing quite often.

(I believe the PC builds are working correctly because they rely on Transport fallbacks so they end up using either Telepathy or Apathy before WebSockets so perhaps my attempt of adding WebSockets transport isn't working at all.)

I found this post which kinda confirmed my suspicions, it says this could be solved by setting up a reverse proxy but this post is almost two years old and .
https://community.playfab.com/questions/21909/secure-websocket-certificate-for-custom-game-serve.html

I am unsure whether I need to set up a certificate in order to connect my WebGL client by WebSockets or if I am just doing something wrong when setting up / creating my server before uploading it.

My goal is to make a WebGL real time multiplayer game from 300 to 3000 connected users at the same time, am I in the right direction? Is it possible to use Playfab with WebGL and websockets for this kind of project?

Thanks.
unity3dCustom Game Servers
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

scottadams avatar image scottadams commented ·

Were you able to get a reverse proxy working with Playfab?

1 Like 1 ·
Sarah Zhang avatar image
Sarah Zhang answered

Theoretically, PlayFab Multiplayer Server 2.0 offers the game server hosting service, it both provides options of TCP and UDP protocols. It can be used in such projects. But currently, there is not an official WebSocket-based multiplayer-game sample that is tested and verified available. There has not been an out-of-the-box solution to the problem of WebSocket certificates.

Besides, the thread you mentioned is a discussion of PlayFab legacy server. PlayFab Multiplayer 2.0 is hosting game servers on Azure. You can try to find an authoritative cert which supports Azure. Or if you can find a mature multiplayer-game solution based on WebRTC, you can consider using it instead of WebSocket.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

scottadams avatar image
scottadams answered

WebGL uses Webs Sockets as a reliable transport only. There is no unreliable transport (like UDP) available to the WebGL client from Unity that I could find.

You will find connect connecting that many clients to a central server will be a big problem. WebGl is also single threaded and that can cause processing issues.

Take a look at WebRTC as a better solution. Or wait for the new networking stack that Unity is currently creating.

I ended up adding Unity store asset WebRTC Video Chat plugin to get access to the underling webRTC functionality. This helped a lot.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.