# Easy WebGL Hosting with PlayFlow

## How PlayFlow makes WebGL hosting easy

For seamless WebGL gaming experiences in web browsers, secure WebSocket connections are crucial, but configuring them can be complex. Often, developers end up managing certificates and networking issues, which can be time-consuming. **With PlayFlow,** however, you only need to enable a simple option to handle these concerns effortlessly.

## Before we begin...

This tutorial assumes you've read the [getting-started-with-playflow](https://fish-networking.gitbook.io/docs/guides/server-hosting/services/playflow-cloud/getting-started-with-playflow "mention") tutorial already. In the following steps we will convert our project support WebGL.

{% stepper %}
{% step %}

#### Install Bayou

For FishNet connections on WebGL we will need to use a web supported transport; there are multiple available, but this tutorial will be using [Bayou](https://fish-networking.gitbook.io/docs/fishnet-building-blocks/transports/bayou). Head over to the Bayou Github repo and download the most recently released `unitypackage` file and then import it into your project.

{% embed url="<https://github.com/FirstGearGames/Bayou/releases/latest>" %}

<figure><img src="https://1328095063-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MheH2hMo3djr9VSyxTE%2Fuploads%2Fgit-blob-17b039ce8bba9ea2f5977beb5724b14fb39cec24%2Fbayou-latest-release.png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Add Bayou to your Network Manager

Now that **Bayou** is imported into your project, you can select your [NetworkManager](https://fish-networking.gitbook.io/docs/fishnet-building-blocks/components/managers/network-manager) and add the component to it.

<figure><img src="https://1328095063-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MheH2hMo3djr9VSyxTE%2Fuploads%2Fgit-blob-8d47e609c001d8391a3af75dbdfdc6cc32d0bc2c%2Fbayou-added-to-networkmanager.png?alt=media" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
If you have more than one [transport](https://fish-networking.gitbook.io/docs/fishnet-building-blocks/transports) on your **NetworkManager**, such as [Tugboat](https://fish-networking.gitbook.io/docs/fishnet-building-blocks/transports/tugboat), then you will need to add the [TransportManager](https://fish-networking.gitbook.io/docs/fishnet-building-blocks/components/managers/transportmanager) component, and drag Bayou into its **Transport** field to set it as the active one.
{% endhint %}
{% endstep %}

{% step %}

#### Enable WSS

In the Bayou component, enable the **Use WSS** option. This will tell Bayou to use Web Socket Secure. Doing this will show a bunch of **SSL Configuration** options below, but we don't need to do anything with them for this setup.

<figure><img src="https://1328095063-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MheH2hMo3djr9VSyxTE%2Fuploads%2Fgit-blob-81ec5593f5bc177af266fc3bbaef5a15c672ec4d%2Fbayou-wss-enabled.png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Build your PlayFlow server

Open the PlayFlow Cloud Window from the Unity toolbar (**PlayFlow → Playflow Cloud**).

Click the **Upload Server** button to build and upload your Unity server.

<figure><img src="https://1328095063-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MheH2hMo3djr9VSyxTE%2Fuploads%2Fgit-blob-7e273977708653447babe03aa8ba33e8ac0da606%2Fplayflow-uploading-server.png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Set the correct PlayFlow port protocol

Open the [PlayFlow dashboard](https://app.playflowcloud.com/) in your browser and navigate to the **Configuration** tab. Edit or add your port and choose the **TCP** protocol and be sure to **Enable TLS**.

<figure><img src="https://1328095063-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MheH2hMo3djr9VSyxTE%2Fuploads%2Fgit-blob-d23464a03e9072185fd92232e92b5c58b8c46fd8%2Fplayflow-tcp-tls.png?alt=media" alt=""><figcaption><p>Choosing the correct protocol for WebGL</p></figcaption></figure>
{% endstep %}

{% step %}

#### Start a PlayFlow server

Now head over to the **Server** tab in PlayFlow and create your server instance.

<figure><img src="https://1328095063-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MheH2hMo3djr9VSyxTE%2Fuploads%2Fgit-blob-f50f85802605794440671ef1af3de755aea20581%2Fplayflow-create-webgl-server.png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

#### Prepare your client build

If you click on your server instance's **Details**, you will see a **Host** and **External Port** that you will be able to connect your clients to. Open Unity, select the Bayou component, and enter these into the **Client Address** and **Port** fields respectively.

<div><figure><img src="https://1328095063-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MheH2hMo3djr9VSyxTE%2Fuploads%2Fgit-blob-f0ae1e7a2fbbb511d238dbc65d820552ce5e9968%2Fplayflow-webgl-address-port.png?alt=media" alt=""><figcaption></figcaption></figure> <figure><img src="https://1328095063-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MheH2hMo3djr9VSyxTE%2Fuploads%2Fgit-blob-d0be20ced38d150c0e8a15c5157432948bb45314%2Fbayou-webgl-fields-entered.png?alt=media" alt=""><figcaption></figcaption></figure></div>
{% endstep %}

{% step %}

#### Building your WebGL client

Now let's build the WebGL client. In your Unity build profiles, be sure to switch to the **Web Platform** and then build your game. Once that's done you can zip the built files and upload it to your chosen hosting site and run your game in the browser!

<figure><img src="https://1328095063-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MheH2hMo3djr9VSyxTE%2Fuploads%2Fgit-blob-a2c2e36d9d1f595e9bc1c3960730c93b99fd88ec%2Fzipped-webgl-files.png?alt=media" alt=""><figcaption></figcaption></figure>

For this test we have created a project on Itch.io and uploaded the client build to it.

<figure><img src="https://1328095063-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MheH2hMo3djr9VSyxTE%2Fuploads%2Fgit-blob-a1dab56a2d56860c9f265fee2c4efb14fca814ac%2Fitch.io-uploaded-webgl-game.png?alt=media" alt=""><figcaption></figcaption></figure>
{% endstep %}
{% endstepper %}

## Success!

Just like that, we were able to create a server and have our clients in the web browser securely connect to it. If you want to check out more of their features, you can check out their documentation here: <https://documentation.playflowcloud.com/>

You are also encouraged to join their <i class="fa-discord">:discord:</i> Discord server here: <https://discord.gg/P5w45Vx5Q8>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://fish-networking.gitbook.io/docs/guides/server-hosting/services/playflow-cloud/easy-webgl-hosting-with-playflow.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
