md-weber / md-weber/webrtc_tutorial
Auto reconnect when the connection is disconnected or fails
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 127
- Forks
- 80
- PR merge metrics
- No merged PRs in 30d
Description
thanks, for the great🌟 repo on webRTC in flutter. I
'm working on this for months, and facing some problems. (I'm working on flutter web)
-
Sometimes 2 different systems doesn't connect to each other, sometimes need to hit 3-4 times joinRoom button for connection.
-
Big problem-Sometimes connection establishes after then if it disconnected/ failed to connect in the mid of meeting, there should be a method of reconnectAgain. I tried to reconnect by putting joinRoom method but this approach is wrong or not working. here is the code:
`
void registerPeerConnectionListeners() {
peerConnection?.onIceGatheringState = (RTCIceGatheringState state) => debugPrint('ICE gathering state changed: $state');peerConnection?.onConnectionState = (RTCPeerConnectionState state) {
debugPrint('Connection state change: $state');
if (state == RTCPeerConnectionState.RTCPeerConnectionStateFailed) {
debugPrint('it is failed');
// reconnectIfNeeded();
} else if (state == RTCPeerConnectionState.RTCPeerConnectionStateConnected) {
debugPrint('it is connected now');
} else if (state == RTCPeerConnectionState.RTCPeerConnectionStateDisconnected) {
debugPrint('it is RTCPeerConnectionStateDisconnected');
// reconnectIfNeeded();
}
};peerConnection?.onSignalingState = (RTCSignalingState state) => debugPrint('Signaling state change: $state');
peerConnection?.onIceGatheringState = (RTCIceGatheringState state) {
debugPrint('ICE connection state change: $state');
if (state == RTCIceGatheringState.RTCIceGatheringStateComplete) {
debugPrint(' RTCIceGatheringState.RTCIceGatheringStateComplete');
} else if (state == RTCIceGatheringState.RTCIceGatheringStateGathering) {
debugPrint(' RTCIceGatheringState.RTCIceGatheringStateGathering');
} else if (state == RTCIceGatheringState.RTCIceGatheringStateNew) {
debugPrint(' RTCIceGatheringState. RTCIceGatheringStateNew');
}
};peerConnection?.onAddStream = (MediaStream stream) {
debugPrint("Add remote stream");
onAddRemoteStream?.call(stream);
remoteStream = stream;
};
}
///////
void reconnectIfNeeded() {
if (peerConnection != null &&
(peerConnection!.connectionState == RTCPeerConnectionState.RTCPeerConnectionStateDisconnected ||
peerConnection!.connectionState == RTCPeerConnectionState.RTCPeerConnectionStateFailed)) {
debugPrint('Reconnecting...');
// joinRoom(); this is not working need to add another logic, how can I reconnect again
}
}
`
thanks in advance
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing registerPeerConnectionListeners, reconnectIfNeeded, and joinRoom, paying attention to the peerConnection state transitions shown in the issue. Define a reconnection flow for disconnected or failed connections that does not require repeatedly pressing joinRoom, and verify that an interrupted meeting can connect again.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- dart, flutter
- Domain
- audio-video-rtc, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 20/100