Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create my own STUN or TURN server using java

I have been working on a video chat application using WebRTC and using Java Websocket as a Signalling server.

This application is working successfully on Tomcat.

Currently I am using​ Google's STUN server.

var pc_config = {"iceServers": [{"url": "stun:stun.l.google.com:19302"}]}; var pc = new RTCPeerConnection(pc_config);

I don't want to relay on a public or 3rd party STUN server, like above.

Since my application will be published to public Tomcat server with dedicated domain. I want use/setup my own STUN or TURN server.

Can I do that with Tomcat?
Are there any stable open-source libraries available for this?

Please point me to an example if any such.

like image 302
Kishor Prakash Avatar asked May 19 '17 14:05

Kishor Prakash


2 Answers

I think trying to cram signaling and NAT traversal (=STUN/TURN server) is the wrong approach. The way you handle scaling with them are different, and the surface of each that you end up exposing towards the open internet is also different.

Due to these reasons, there's no real problem of using a different language/tech for the STUN/TURN server. I'd go with either coturn or restund here.

There are also a few managed commercial services you can use instead of deploying your own, and they really aren't expensive.

like image 100
Tsahi Levent-Levi Avatar answered Sep 19 '22 05:09

Tsahi Levent-Levi


The better way is to use an open source solution as a service on your server. Example: https://github.com/coturn/rfc5766-turn-server/ - it is functional and stable, supports additional features.

AFAIK, there are no Java STUN/TURN libs that can work under Tomcat. Although, there are some open source Java-based projects, like this one: https://github.com/jitsi/turnserver

like image 31
fycth Avatar answered Sep 18 '22 05:09

fycth