Skip to content

Web Sockets

For demo sketches that use connectivity, a web sockets server is needed, unfortunately not provided by Five Server.

If you’re running code in a hosted environment, please see the guides:

Run on your own machine

If you’re running the demos on your local machine, the recommended approach is to continue to run them as you do normally, but start yourself up a websocket server on Glitch.

  1. Start up a remix of this Glitch project.
  2. When you set up Remote, use the URL to your Glitch project.

For example:

const settings = Object.freeze({
remote: new Remote({
allowNetwork: true,
websocket: `wss://MY-ZANY-PROJECT-NAME.glitch.me/ws`
})
});

If you are using a home wifi network, or have your devices hot-spotted together, you can open your webserver by its IP address. When Five Server starts up, you’ll see something like:

Five Server running at:
> Local: http://localhost:5500
> Network: http://192.168.0.141:5500

On your mobile device (again, if it’s on the same wifi network) you should be able to open the URL given for ‘Network’. In the above example, http://192.168.0.141:5500.

To access your sketches outside of your network, you’ll need to add ngrok to the mix. Please see ngrok for more on this.