Reputation: 373
UPDATE 1: I tried changing the video constraint like this
var mediaConstraints = {
audio: true, // We want an audio track
video: {
width: { min: 160, ideal: 320, max: 640 },
height: { min: 120, ideal: 240, max: 480 },
}
};
It has improved the call a bit. The video does still hang and cause sometimes the call to drop. I think this means the issue is slow network and not NAT.
I am still looking for answers to improve this call connection on the slow speeds.
ORIGINAL POST:
I know there are few similar questions on SO but what I am trying to ask hasn't been asked as far as my search is concerned.
webRTC video call works fine within my local network. But when I try to call my friend over the internet it sucks. I and my friend are on the same ISP and we are living in same geographic area within few miles of distance. So I would assume that this issue wouldn't be due to some NATs or firewalls but maybe I am wrong. Initially our call connects audio goes through and video goes through just few bits and then freezes or just hangs before the call drops. If we disable the video the call lasts longer and doesn't generally drop. Could this be slow network issue because we both are in the region were the internet speeds are around 150Kbps? But how does then whatsapp video calling work?
I intend to use this app within this same region with multiple ISPs and same low speeds. But if the issue is not due to speed and is due to NAT etc for which I would need TURN server then I think 100% of my calls will go through TURN and that will be very expensive for me.
I need advice if you have had any such experience or think I could improve this call setup with this low internet speed.
If this is of any help here my constraint config is:
var mediaConstraints = {
audio: true, // We want an audio track
video: {
width: { min: 240, ideal: 720, max: 1080 },
height: { min: 240, ideal: 720, max: 1080 },
}
};
Thank you
Upvotes: 2
Views: 1366
Reputation: 373
I am posting the answer here in case anyone comes across this.
Reason was that I was closing the connection whenever ICE state changed to disconnected
. Sometimes due to slow network or some other issue ICE may change state to disconnect
temporarily. Normally, it will recover within one or two seconds on its own. The way to handle this state properly is to determine when the disconnected
is permanent and when temporary. In the answer to the question here I count the bytes that have been received over two seconds. If bytes have increased I consider disconnect
otherwise permanent and then close the connection.
Upvotes: 1
Reputation: 1469
One thing you cab do is using Simulcast which is natively part of webrtc. This will make the sender have streams of different quality. Then the consuming part will automatically choose the best stream based on the network connection.
example: https://www.w3.org/TR/webrtc/#simulcast-example
Upvotes: 0