Chat/nat traversal

Ask tech team
From QuickBlox Developers (API docs, code samples, SDK)
Jump to: navigation, search

NAT traversal - why do you need it

You don't actually have to worry about things like STUN/TURN servers, NAT traversal etc when building apps using QuickBlox SDK - all of that is taken care of automatically. However we assume you want to know why it is used. So, you may know that both audio and video traffic is typically peer-to-peer which is true for both direct http streaming and most of VoIP libraries. In QuickBlox we use direct HTTP streaming connection and the problem with such p2p connection when done directly is that in some cases it just won't work because of NAT (network address translations) gateways (different routers, firewalls, network types between two end users) which breaks the connectivity. To resolve that and traverse the gateways you need to implement one of the NAT traversal techniques otherwise your audio / video call will only work if both users are on the same network or in other cases where there are no NAT gateways in between.

How it works

1. Your app initiates video/audio call via QuickBlox Video Chat SDK.
2. QB library tries to establish direct connection to the other user.
3. If connection doesn't get established in N (typically 3) seconds the QB Chat server is called to establish handshake between two end users. This works both for XMPP and WebRTC connections.
4. TURN server integrated into QB Chat server comes into play carrying out NAT traversal.

This approach works in 99,99% cases and we have made a lot of tests and adjustments internally and with early adopters of QuickBlox making sure it works between different Wi-Fi, 3G and 4G networks. There have been a lot of updates and the SDK is really stable now.

Code samples / Tutorials

There are no code samples / tutorials for NAT traversal as this is integrated into SDK library and on server-side. Let us know in discussion section here if you have any questions or comments regarding NAT traversal in video / audio calling with QuickBlox and we will look into that as soon as possible.