By Admin on Wednesday, 18 August 2021
Category: All

Delphi TURN Server Component (3/4)

​From sgcWebSockets 4.5.2, TURN protocol is supported on Server components.

TsgcTURNServer is the server that implements the TURN Protocol and allows to process requests from TURN clients. The component inherits from TsgcSTUNServer, so all methods and properties are available on TsgcTURNServer.

TURN Server supports Long-Term Authentication, Allocation, Permissions, Channel Data and more.

Basic Usage 

Usually TURN servers runs on UDP port 3478 and require Long-Term credentials, so in order to configure a TURN server, set the listening port (by default 3478) and start the server.

Configure the server

Set the property Active = True to start the STUN server.

Allocations 

All TURN operations revolve around allocations and all TURN messages are associated with an Allocation. An allocation consists of:


When a TURN client sends an Allocate request, this TURN message is processed by server and tries to create a new Relayed Transport Address. By default, if there is any available UDP port, it will create a new Relayed Address, but you can use OnTURNBeforeAllocate event to reject a new Allocation request.

​If the process continues, the server creates a new allocation and the event OnTURNCreateAllocation is called. This event provides information about the Allocation through the class TsgcTURNAllocationItem.

​When the Allocation expires or is deleted receiving a Refresh Request from client with a lifetime of zero, the event OnTURNDeleteAllocation event is fired.

Related Posts