WebRTC

VidMeet is the WebRTC-based video calling system built into GKSPHONE. This guide explains every setting in the Cfg.VidMeet block inside LUA/config/serverconfig.lua and walks you through both setup modes.


Configuration Block Reference

Cfg.VidMeet = {
    Enabled    = true,

    -- ICE Server type: "cloudflare" | "manual"
    IceServer  = "manual",

    Cloudflare = {
        TokenID  = "",
        ApiToken = "",
        TTL      = 86400
    },

    ManualIceServers = {
        { urls = "stun:stun.cloudflare.com:3478" },
        { urls = "stun:stun.l.google.com:19302" },
        -- ...
    }
}
Key
Type
Default
Description

Enabled

boolean

true

Enables or disables the video call feature entirely

IceServer

string

"manual"

ICE server mode: "cloudflare" or "manual"

Cloudflare.TokenID

string

""

Cloudflare TURN Server Application ID (Turn Token ID)

Cloudflare.ApiToken

string

""

Cloudflare API Token (with Calls Edit permission)

Cloudflare.TTL

number

86400

TURN credential lifetime in seconds (86400 = 24 hours)

ManualIceServers

array

(STUN list)

RTCIceServer[] used when IceServer = "manual"


ICE Server Modes

Mode 1: "manual" (Default)

Uses the ManualIceServers array you define. The default list contains public STUN servers only, which work for most peer-to-peer connections but may fail when both players are behind strict NATs or firewalls (e.g., corporate networks, CGNAT).

When to use: Development, testing, or when your player base has standard home networks.

Limitations:

  • STUN only β€” no TURN relay fallback

  • Video calls may fail for ~15–20 % of NAT configurations

  • No cost, no credentials needed

Adding a TURN server (recommended for production):

turns: uses TLS (port 5349) and is required for HTTPS pages.


Uses Cloudflare Realtime TURN Serverarrow-up-right to generate short-lived TURN credentials automatically. Cloudflare's global anycast TURN network provides low-latency relays worldwide.

When to use: Production servers, large player bases, or whenever you want maximum call reliability.

Advantages over manual TURN:

  • Global Anycast network β€” players connect to the nearest relay

  • Auto-rotating credentials (no static secrets in config)

  • Pay-as-you-go pricing (first 1,000 participant-minutes/month are free)

  • No self-hosted infrastructure to maintain


Setting Up Cloudflare TURN Server (Step-by-Step)

1

Step 1 β€” Create a Cloudflare Account

Go to dash.cloudflare.comarrow-up-right and sign up or log in.

2

Step 2 β€” Navigate to TURN Server

  1. In the left sidebar, expand Media.

  2. Expand Realtime under it.

  3. Click TURN Server.

Navigation path: Media β†’ Realtime β†’ TURN Server

3

Step 3 β€” Create a TURN Server App

  1. On the TURN Server page, click Create a TURN Server app.

  2. Give it a name (e.g., gksphone-vidmeet).

  3. After clicking create, you will see two values on the same page:

    • Turn Token ID β€” this is your TokenID

    • API Token (64-character hex string) β€” this is your ApiToken

circle-exclamation
4

Step 4 β€” Configure serverconfig.lua

5

Step 5 β€” Verify

Restart your FiveM server and attempt a video call in-game. Check the server console for any Cloudflare API errors.


TTL (Credential Lifetime)

The TTL value controls how long each set of TURN credentials remains valid. The server generates fresh credentials for every new call.

TTL Value
Duration
Recommendation

3600

1 hour

Default β€” ideal for ~30 min sessions

86400

24 hours

Unnecessarily long, increases exposure risk

604800

7 days

Debug only, never use in production

Average VidMeet session is ~30 minutes. 3600 gives a comfortable 1-hour window while minimizing the risk of credential misuse if intercepted.


STUN vs TURN β€” What's the Difference?

Protocol
Purpose
Required when

STUN

Discovers your public IP/port

Always (free, low traffic)

TURN

Relays media through a server

One or both peers are behind strict NAT/firewall

Most home routers work fine with STUN only. TURN becomes essential when:

  • Players are on mobile data (CGNAT is common)

  • Players are behind corporate/university firewalls

  • Players are on VPNs that block peer-to-peer UDP


Troubleshooting

Symptom
Likely Cause
Fix

Video calls connect but drop immediately

NAT traversal failing

Add a TURN server or switch to Cloudflare mode

"Cloudflare API error 403" in console

Wrong ApiToken or missing permission

Recreate token with Calls Edit permission

"Cloudflare API error 404" in console

Wrong TokenID

Double-check Turn Token ID in Media β†’ Realtime β†’ TURN Server

Calls work locally but not on production

Server firewall blocking UDP

Open UDP 3478 (STUN/TURN) or use turns: on TCP 5349

High call latency for some players

STUN only, no TURN relay

Enable TURN β€” Cloudflare mode routes to nearest PoP


Last updated