Reputation: 31
I am using Twilio Android SDK in our android app. It works well but sometimes stopped listening for incoming connections callback is called with error = "31003". I read the error code with explaining is "Connection timeout" but don't know what is the exactly cased to the error. Could you please help me to describe the detail of this error and what should i do for this case. Thanks so much.
Upvotes: 1
Views: 628
Reputation: 21730
Twilio developer evangelist here.
We use WebRTC for communications, and a 31003 error indicates ICE disconnect. This can occur when the browser or device believes a previously active connection is no longer properly connected. This can happen due to changing network conditions.
What you need to do in this case is watch for when this error is raised, and try to connect again. In most cases I've seen this happening it was when using cellular network, or if my wifi had intermittent availability.
One other thing you can do is keep an eye on the ConnectivityManager to see wether you're connected or not. Something like this would work:
ConnectivityManager cm =
(ConnectivityManager)context.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
boolean isConnected = activeNetwork != null &&
activeNetwork.isConnectedOrConnecting();
Now all you need to do is check the value of isConnected
for changes, and when that changes, you know the error will be raised, so can try to create a new connection with Twilio again.
Hope this helps you.
Upvotes: 1