Xirsys is one of the few original pioneers of WebRTC infrastructure with their TURN Server offerings. Today, they've extended their services to custom installation and hosting of practically all the possible WebRTC servers in the world including Jitsi video bridge, Janus video room, Medooze, LiveSwitch, and Kurento media server. With a footprint in 11 data centers across the world, they are the most versatile and reliable WebRTC hosting solution on the market.
Xirsys is built upon patented technology providing a distributed deployment architecture for advanced reliability, scalability and extendability. This creates superior uptime and allows for arbitrary 3rd party software to quickly become part of the Xirsys service and accessible through the API.
The Xirsys function endpoint substitutes a web server for providing WebRTC clients with tokens for TURN provider access. Conventionally, a website's server will be the secure granter of access, by providing temporary access tokens to clients. This way, malicious app developers cannot hijack your company's Xirsys account, racking up video streaming bandwidth on your Xirsys bill.
PubNub Functions takes the web server hosting component out of the equation for the equation for the developer, by making the service serverless. Think of this custom API as a microservice, hosted in the cloud, that can be deployed instantly with the click of a button.
The Xirsys endpoint you deploy with PubNub Functions provides two REST actions:
- A GET route that returns a temporary token (60 minute TTL). A client can request Xirsys credentials for up to 1 hour after they retrieve a token.
- A PUT route that returns a list of ICE servers and temporary credentials from Xirsys. The client must provide a valid token to this route. The token distribution and TTL is handled entirely by the PubNub Functions KV Store.
Before deploying, you must:
Sign up for a Xirsys account
Get your Xirsys channel, ident, and secret from the Xirsys dashboard
Add the values you get from Xirsys as "ident:secret" to the PubNub Functions Vault with the key "xirsys".
Replace the channel variable at the top of the code with your Xirsys channel
Replace the origin URL with your app's URL
Make sure the event handler type is "On Request"
Click the copy URL button and paste the URL into your client application code
Read this WebRTC with Xirsys tutorial for a more in-depth walkthrough.
The GET and PUT HTTP requests can be made to the Function endpoint URL. The get request returns a 1-hour life token, which can be used to make a PUT request to the same API. The PUT request will return WebRTC TURN server access credentials for Xirsys.
// Get a 1 hour token from your PubNub Functions API let turnToken; request(url, 'GET').then((response) => { // Response is a unique base64 encoded string turnToken = response });
The PUT request will return WebRTC TURN server access credentials for Xirsys. For more on web development with these credentials, take a look at the MDN website documentation on WebRTC and TURN.
// Get new TURN server credentials from Xirsys request(url, 'PUT', { 'headers': { 'tok': turnToken } }).then((response) => { rtcConfig.iceServers = [response]; // Response object looks like this: // { // "urls": [ // "stun:w2.xirsys.com", // "turn:w2.xirsys.com:80?transport=udp", // "turn:w2.xirsys.com:3478?transport=udp", // "turn:w2.xirsys.com:80?transport=tcp", // "turn:w2.xirsys.com:3478?transport=tcp", // "turns:w2.xirsys.com:443?transport=tcp", // "turns:w2.xirsys.com:5349?transport=tcp" // ], // "username": "dc878d7e-e3b0-11e8-be12-f55daaa747ad", // "credential": "dc849e01-e3a0-11e8-acd1-7d1bbed496e7" // } });
Need help? Contact PubNub Support.
Copyright (c) 2018 PubNub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.