socialstack-huddle-server

Socialstack huddle server, built on the wonderful mediasoup.org project

Usage no npm install needed!

<script type="module">
  import socialstackHuddleServer from 'https://cdn.skypack.dev/socialstack-huddle-server';
</script>

README

SocialStack Huddle Server

This is the Huddle server - it carries video and audio chat. Typically deployed as a cluster.

Dependencies

Huddle server sits directly on top of Mediasoup, so its dependencies directly match Mediasoups. For some guidance, see platform particulars below.

Ubuntu

There's a shell file that you can follow here.

Windows

If you're installing on windows, that's at least the following:

  • Python 2.x
  • npm i -g windows-build-tools
  • Append the path of MSBuild.exe folder to the Windows PATH environment variable (e.g. “C:\Program Files (x86)\MSBuild\14.0\Bin”).
  • Create a new Windows environment variable GYP_MSVS_VERSION with the version of Visual Studio as value (e.g. “2017” for Visual Studio 2017).
  • npm i -g socialstack-huddle-server

Other

See mediasoup for more detail on the required software and dependencies for your target platform.

Installation

After setting up the dependencies, go ahead and install Huddle:

npm install -g socialstack-huddle-server

Starting the server

A just installed Huddle server requires no additional configuration to work locally. Run the following to get it started:

socialstack-huddle-server start

Assuming this is running on localhost, you'll then be able to confirm your server is up and responding by going here:

http://localhost:4443/

Production

In a production deployment, you should use something like NGINX to add https support to the Huddle websocket. A sample NGINX config file is available here.

Configuring a Socialstack site to use a Huddle server

First, go to /pki on your Huddle server. For example if it's running on localhost:

http://localhost:4443/pki

Copy the public key (without the quotes) - you'll need it in a moment. Next, via the admin panel (or straight in the database), go to the "Huddle Servers" section and add a new entry.

  • Address is the hostname of your Huddle server, for example localhost:4443 or myhuddleserver.example.com in production.
  • PublicKey is the value you copied above. Make sure it doesn't include any " when pasting it in.

You may need to restart the Socialstack site API for the change to apply. You'll then be able to create and join Huddles on the site.

Huddle presence

Socialstack sites optionally can be informed about a user's presence when they enter and exit huddles. This works via a webhook - the huddle server makes a web request to the Socialstack API to inform that a user's presence has changed. To make sure that the source huddle server can be trusted to make this request, each Huddle server has a public key which you can obtain by going to e.g. http://localhost:4443/pki (i.e. the location of your Huddle server, plus /pki). Here you'll see a public key which you should copy into your site_huddleserver table. This part is optional but highly recommended.

Huddle server persistent data

Huddle servers have a small SQLite database as well as retain a private key and potentially other persistent data. This is stored in the appdata folder of the given platform, and you can obtain the filepath via the following command:

socialstack-huddle-server configuration

Clearing persistent data

The SQLite database is used to store webhooks that need to be triggered. Sometimes you may need to clear this database out - you can do it either by outright deleting the database.sqlite file in the above persistent data folder, or alternatively run either of the following commands:

  • socialstack-huddle-server database -clear

Clears the whole database.

  • socialstack-huddle-server database -clear -host "mysite.com"

Clears a particular Socialstack site from the database. This is only the case where a Huddle server is being shared by multiple sites.