Add TURN server to android webRtc native





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







3















I'm working on WebRtc native android application. Im also compiling io.pristine lib. Im able to establish calls between two devices only if both of them are connected to the wifi. In case when one of the devices is connected to the cellular network im not able to establish call. I read any possible forum out there and its look like I need TURN server. I already run my own TURN server but idk how I can force the app to use this server. Any help is welcome. Thank you!!










share|improve this question























  • could you guide me how to build io.pristine lib.

    – M.Hefny
    Aug 16 '17 at 23:33











  • Strictly speaking, just a STUN server will be enough, but TURN will also provide a fallback if your clients are not able to establish a peer-to-peer connection. There are free public STUN servers out there, e.g. stun.l.google.com:19302.

    – jamix
    Jan 3 '18 at 10:19


















3















I'm working on WebRtc native android application. Im also compiling io.pristine lib. Im able to establish calls between two devices only if both of them are connected to the wifi. In case when one of the devices is connected to the cellular network im not able to establish call. I read any possible forum out there and its look like I need TURN server. I already run my own TURN server but idk how I can force the app to use this server. Any help is welcome. Thank you!!










share|improve this question























  • could you guide me how to build io.pristine lib.

    – M.Hefny
    Aug 16 '17 at 23:33











  • Strictly speaking, just a STUN server will be enough, but TURN will also provide a fallback if your clients are not able to establish a peer-to-peer connection. There are free public STUN servers out there, e.g. stun.l.google.com:19302.

    – jamix
    Jan 3 '18 at 10:19














3












3








3


1






I'm working on WebRtc native android application. Im also compiling io.pristine lib. Im able to establish calls between two devices only if both of them are connected to the wifi. In case when one of the devices is connected to the cellular network im not able to establish call. I read any possible forum out there and its look like I need TURN server. I already run my own TURN server but idk how I can force the app to use this server. Any help is welcome. Thank you!!










share|improve this question














I'm working on WebRtc native android application. Im also compiling io.pristine lib. Im able to establish calls between two devices only if both of them are connected to the wifi. In case when one of the devices is connected to the cellular network im not able to establish call. I read any possible forum out there and its look like I need TURN server. I already run my own TURN server but idk how I can force the app to use this server. Any help is welcome. Thank you!!







android webrtc turn






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jun 16 '17 at 2:27









AlexanderAlexander

58112




58112













  • could you guide me how to build io.pristine lib.

    – M.Hefny
    Aug 16 '17 at 23:33











  • Strictly speaking, just a STUN server will be enough, but TURN will also provide a fallback if your clients are not able to establish a peer-to-peer connection. There are free public STUN servers out there, e.g. stun.l.google.com:19302.

    – jamix
    Jan 3 '18 at 10:19



















  • could you guide me how to build io.pristine lib.

    – M.Hefny
    Aug 16 '17 at 23:33











  • Strictly speaking, just a STUN server will be enough, but TURN will also provide a fallback if your clients are not able to establish a peer-to-peer connection. There are free public STUN servers out there, e.g. stun.l.google.com:19302.

    – jamix
    Jan 3 '18 at 10:19

















could you guide me how to build io.pristine lib.

– M.Hefny
Aug 16 '17 at 23:33





could you guide me how to build io.pristine lib.

– M.Hefny
Aug 16 '17 at 23:33













Strictly speaking, just a STUN server will be enough, but TURN will also provide a fallback if your clients are not able to establish a peer-to-peer connection. There are free public STUN servers out there, e.g. stun.l.google.com:19302.

– jamix
Jan 3 '18 at 10:19





Strictly speaking, just a STUN server will be enough, but TURN will also provide a fallback if your clients are not able to establish a peer-to-peer connection. There are free public STUN servers out there, e.g. stun.l.google.com:19302.

– jamix
Jan 3 '18 at 10:19












1 Answer
1






active

oldest

votes


















4














You need to set the TURN server when creating the PeerConnection.



It will go something like this:



    // Set ICE servers
List<PeerConnection.IceServer> iceServers = new ArrayList<>();
iceServers.add(new org.webrtc.PeerConnection.IceServer("stun:xxx.xxx.xxx.xxx"));
iceServers.add(new org.webrtc.PeerConnection.IceServer("turn:xxx.xxx.xxx.xxx:3478", "username", "credential"));

// Create peer connection
final PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
PeerConnectionFactory factory = new PeerConnectionFactory(new PeerConnectionFactory.Options());
MediaConstraints constraints = new MediaConstraints();
PeerConnection peerConnection = factory.createPeerConnection(iceServers, constraints, new YourPeerConnectionObserver());


I have not run this code, but you should get the idea.






share|improve this answer





















  • 1





    just add bracket in the end of the 2nd and 3rd line.

    – Uriel Frankel
    Dec 24 '17 at 10:17











  • Hey @Mikko, my ICE servers looks like: "stun:URL", "turns:URL:433?transport=tcp", "turns:URL:5349?transport=tcp" But I see only typ host and typ srflx Ice Candidates in signaling channel. I'm able to establish call when devices are connected to same hotspot but gets onIceConnectionChange: state=FAILED when one of them uses cellular network

    – Dmytro Batyuk
    Oct 22 '18 at 20:09














Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44579855%2fadd-turn-server-to-android-webrtc-native%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









4














You need to set the TURN server when creating the PeerConnection.



It will go something like this:



    // Set ICE servers
List<PeerConnection.IceServer> iceServers = new ArrayList<>();
iceServers.add(new org.webrtc.PeerConnection.IceServer("stun:xxx.xxx.xxx.xxx"));
iceServers.add(new org.webrtc.PeerConnection.IceServer("turn:xxx.xxx.xxx.xxx:3478", "username", "credential"));

// Create peer connection
final PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
PeerConnectionFactory factory = new PeerConnectionFactory(new PeerConnectionFactory.Options());
MediaConstraints constraints = new MediaConstraints();
PeerConnection peerConnection = factory.createPeerConnection(iceServers, constraints, new YourPeerConnectionObserver());


I have not run this code, but you should get the idea.






share|improve this answer





















  • 1





    just add bracket in the end of the 2nd and 3rd line.

    – Uriel Frankel
    Dec 24 '17 at 10:17











  • Hey @Mikko, my ICE servers looks like: "stun:URL", "turns:URL:433?transport=tcp", "turns:URL:5349?transport=tcp" But I see only typ host and typ srflx Ice Candidates in signaling channel. I'm able to establish call when devices are connected to same hotspot but gets onIceConnectionChange: state=FAILED when one of them uses cellular network

    – Dmytro Batyuk
    Oct 22 '18 at 20:09


















4














You need to set the TURN server when creating the PeerConnection.



It will go something like this:



    // Set ICE servers
List<PeerConnection.IceServer> iceServers = new ArrayList<>();
iceServers.add(new org.webrtc.PeerConnection.IceServer("stun:xxx.xxx.xxx.xxx"));
iceServers.add(new org.webrtc.PeerConnection.IceServer("turn:xxx.xxx.xxx.xxx:3478", "username", "credential"));

// Create peer connection
final PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
PeerConnectionFactory factory = new PeerConnectionFactory(new PeerConnectionFactory.Options());
MediaConstraints constraints = new MediaConstraints();
PeerConnection peerConnection = factory.createPeerConnection(iceServers, constraints, new YourPeerConnectionObserver());


I have not run this code, but you should get the idea.






share|improve this answer





















  • 1





    just add bracket in the end of the 2nd and 3rd line.

    – Uriel Frankel
    Dec 24 '17 at 10:17











  • Hey @Mikko, my ICE servers looks like: "stun:URL", "turns:URL:433?transport=tcp", "turns:URL:5349?transport=tcp" But I see only typ host and typ srflx Ice Candidates in signaling channel. I'm able to establish call when devices are connected to same hotspot but gets onIceConnectionChange: state=FAILED when one of them uses cellular network

    – Dmytro Batyuk
    Oct 22 '18 at 20:09
















4












4








4







You need to set the TURN server when creating the PeerConnection.



It will go something like this:



    // Set ICE servers
List<PeerConnection.IceServer> iceServers = new ArrayList<>();
iceServers.add(new org.webrtc.PeerConnection.IceServer("stun:xxx.xxx.xxx.xxx"));
iceServers.add(new org.webrtc.PeerConnection.IceServer("turn:xxx.xxx.xxx.xxx:3478", "username", "credential"));

// Create peer connection
final PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
PeerConnectionFactory factory = new PeerConnectionFactory(new PeerConnectionFactory.Options());
MediaConstraints constraints = new MediaConstraints();
PeerConnection peerConnection = factory.createPeerConnection(iceServers, constraints, new YourPeerConnectionObserver());


I have not run this code, but you should get the idea.






share|improve this answer















You need to set the TURN server when creating the PeerConnection.



It will go something like this:



    // Set ICE servers
List<PeerConnection.IceServer> iceServers = new ArrayList<>();
iceServers.add(new org.webrtc.PeerConnection.IceServer("stun:xxx.xxx.xxx.xxx"));
iceServers.add(new org.webrtc.PeerConnection.IceServer("turn:xxx.xxx.xxx.xxx:3478", "username", "credential"));

// Create peer connection
final PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
PeerConnectionFactory factory = new PeerConnectionFactory(new PeerConnectionFactory.Options());
MediaConstraints constraints = new MediaConstraints();
PeerConnection peerConnection = factory.createPeerConnection(iceServers, constraints, new YourPeerConnectionObserver());


I have not run this code, but you should get the idea.







share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 7 '18 at 8:39

























answered Aug 3 '17 at 21:01









MikkoMikko

9721925




9721925








  • 1





    just add bracket in the end of the 2nd and 3rd line.

    – Uriel Frankel
    Dec 24 '17 at 10:17











  • Hey @Mikko, my ICE servers looks like: "stun:URL", "turns:URL:433?transport=tcp", "turns:URL:5349?transport=tcp" But I see only typ host and typ srflx Ice Candidates in signaling channel. I'm able to establish call when devices are connected to same hotspot but gets onIceConnectionChange: state=FAILED when one of them uses cellular network

    – Dmytro Batyuk
    Oct 22 '18 at 20:09
















  • 1





    just add bracket in the end of the 2nd and 3rd line.

    – Uriel Frankel
    Dec 24 '17 at 10:17











  • Hey @Mikko, my ICE servers looks like: "stun:URL", "turns:URL:433?transport=tcp", "turns:URL:5349?transport=tcp" But I see only typ host and typ srflx Ice Candidates in signaling channel. I'm able to establish call when devices are connected to same hotspot but gets onIceConnectionChange: state=FAILED when one of them uses cellular network

    – Dmytro Batyuk
    Oct 22 '18 at 20:09










1




1





just add bracket in the end of the 2nd and 3rd line.

– Uriel Frankel
Dec 24 '17 at 10:17





just add bracket in the end of the 2nd and 3rd line.

– Uriel Frankel
Dec 24 '17 at 10:17













Hey @Mikko, my ICE servers looks like: "stun:URL", "turns:URL:433?transport=tcp", "turns:URL:5349?transport=tcp" But I see only typ host and typ srflx Ice Candidates in signaling channel. I'm able to establish call when devices are connected to same hotspot but gets onIceConnectionChange: state=FAILED when one of them uses cellular network

– Dmytro Batyuk
Oct 22 '18 at 20:09







Hey @Mikko, my ICE servers looks like: "stun:URL", "turns:URL:433?transport=tcp", "turns:URL:5349?transport=tcp" But I see only typ host and typ srflx Ice Candidates in signaling channel. I'm able to establish call when devices are connected to same hotspot but gets onIceConnectionChange: state=FAILED when one of them uses cellular network

– Dmytro Batyuk
Oct 22 '18 at 20:09






















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f44579855%2fadd-turn-server-to-android-webrtc-native%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents