Closed prabhuc94 closed 1 year ago
When you dispose peerdart, you need to reinitialize it before using it.
When you dispose peerdart, you need to reinitialize it before using it.
I didn't dispose the peerDart. And having one more issue like if user facing network issue peerdart not returning / emitting socket closed / network failed kind of message, it's only printing in log. Kindly check this: flutter: PeerDart: Attempting reconnection to server with ID e0ce28b4-e1c2-40f8-8467-7e09f9d63dcf flutter: PeerDart: Socket open flutter: PeerDart: Server message received:{type: ID-TAKEN, payload: {msg: ID is taken}} [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: Cannot add new events after calling close
flutter: PeerDart: Socket closed.
The id that you initiliaze peerdart class is taken, therefore it could not proceed. But it should throw an error. Do you provide your own id?
The id that you initiliaze peerdart class is taken, therefore it could not proceed. But it should throw an error. Do you provide your own id?
No,
Still same issue! PeerReconnectIssue.txt If you want to replicate the issue kindly try this: "After peer connected turn off internet then connect internet!" I've one suggestion : "void close() => controller.close();" kindly call only this at the time of Peer.dispose(). I hope this can solve the Connection issue!. Kindly advise me if it's wrong!
That's because peerdart is fetching uuid from the server and then store it. This is has nothing todo with peerdart, as peerdart do not listen for connectivity changes. You may dispose and reinitilaze peer object each time connectivity changes, so it fetches new id from the server.
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: No element
0 Stream.first. (dart:async/stream.dart:1575:9)
1 _RootZone.runGuarded (dart:async/zone.dart:1582:10)
2 _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
3 _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
4 _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
5 _ForwardingStream._handleDone (dart:async/stream_pipe.dart:99:10)
6 _ForwardingStreamSubscription._handleDone (dart:async/stream_pipe.dart:161:13)
7 _RootZone.runGuarded (dart:async/zone.dart:1582:10)
8 _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
9 _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
10 _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
11 _SinkTransformerStreamSubscription._close (dart:async/stream_transformers.dart:87:11)
12 _EventSinkWrapper.close (dart:async/stream_transformers.dart:21:11)
13 _WhereTypeStreamSink.close (package:rxdart/src/transformers/where_type.dart:19:31)
14 _SinkTransformerStreamSubscription._handleDone (dart:async/stream_transformers.dart:132:24)
15 _RootZone.runGuarded (dart:async/zone.dart:1582:10)
16 _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
17 _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
18 _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
19 _ForwardingStream._handleDone (dart:async/stream_pipe.dart:99:10)
20 _ForwardingStreamSubscription._handleDone (dart:async/stream_pipe.dart:161:13)
21 _RootZone.runGuarded (dart:async/zone.dart:1582:10)
22 _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
23 _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
24 _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
25 _SyncBroadcastStreamController._sendDone. (dart:async/broadcast_stream_controller.dart:399:22)
26 _BroadcastStreamController._forEachListener (dart:async/broadcast_stream_controller.dart:322:15)
27 _SyncBroadcastStreamController._sendDone (dart:async/broadcast_stream_controller.dart:398:7)
28 _BroadcastStreamController.close (dart:async/broadcast_stream_controller.dart:268:5)
29 StreamEventEmitter.close (package:events_emitter/emitters/stream_event_emitter.dart:117:30)
30 Peer._handleMessage (package:peerdart/src/peer.dart:200:26)
31 Peer._createServerConnection. (package:peerdart/src/peer.dart:121:7)
32 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
33 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
34 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
35 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
36 _MapStream._handleData (dart:async/stream_pipe.dart:218:10)
37 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
38 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
39 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
40 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
41 _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:63:11)
42 _EventSinkWrapper.add (dart:async/stream_transformers.dart:13:11)
43 _WhereTypeStreamSink.add (package:rxdart/src/transformers/where_type.dart:11:19)
44 _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
45 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
46 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
47 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
48 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
49 _WhereStream._handleData (dart:async/stream_pipe.dart:195:12)
50 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
51 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
52 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
53 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
54 _SyncBroadcastStreamController._sendData. (dart:async/broadcast_stream_controller.dart:385:20)
55 _BroadcastStreamController._forEachListener (dart:async/broadcast_stream_controller.dart:322:15)
56 _SyncBroadcastStreamController._sendData (dart:async/broadcast_stream_controller.dart:384:5)
57 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:244:5)
58 StreamEventEmitter.emitEvent (package:events_emitter/emitters/stream_event_emitter.dart:53:51)
59 StreamEventEmitter.emit (package:events_emitter/emitters/stream_event_emitter.dart:92:40)
60 Socket.start. (package:peerdart/src/socket.dart:54:7)
61 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
62 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
63 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
64 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
65 _HandleErrorStream._handleData (dart:async/stream_pipe.dart:253:10)
66 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
67 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
68 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
69 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
70 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:776:19)
71 _StreamController._add (dart:async/stream_controller.dart:650:7)
72 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
73 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
74 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
75 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:776:19)
76 _StreamController._add (dart:async/stream_controller.dart:650:7)
77 _StreamController.add (dart:async/stream_controller.dart:598:5)
78 new _WebSocketImpl._fromSocket. (dart:_http/websocket_impl.dart:1144:21)
79 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
80 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
81 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
82 _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:63:11)
83 _EventSinkWrapper.add (dart:async/stream_transformers.dart:13:11)
84 _WebSocketProtocolTransformer._messageFrameEnd (dart:_http/websocket_impl.dart:332:23)
85 _WebSocketProtocolTransformer.add (dart:_http/websocket_impl.dart:226:46)
86 _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
87 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
88 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
89 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
90 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:776:19)
91 _StreamController._add (dart:async/stream_controller.dart:650:7)
92 _StreamController.add (dart:async/stream_controller.dart:598:5)
93 _Socket._onData (dart:io-patch/socket_patch.dart:2381:41)
94 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
95 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
96 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
97 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:776:19)
98 _StreamController._add (dart:async/stream_controller.dart:650:7)
99 _StreamController.add (dart:async/stream_controller.dart:598:5)
100 _RawSecureSocket._sendReadEvent (dart:io/secure_socket.dart:1114:19)
101 Timer._createTimer. (dart:async-patch/timer_patch.dart:18:15)
102 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
103 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
104 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: No element
0 Stream.first. (dart:async/stream.dart:1575:9)
1 _RootZone.runGuarded (dart:async/zone.dart:1582:10)
2 _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
3 _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
4 _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
5 _ForwardingStream._handleDone (dart:async/stream_pipe.dart:99:10)
6 _ForwardingStreamSubscription._handleDone (dart:async/stream_pipe.dart:161:13)
7 _RootZone.runGuarded (dart:async/zone.dart:1582:10)
8 _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
9 _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
10 _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
11 _SinkTransformerStreamSubscription._close (dart:async/stream_transformers.dart:87:11)
12 _EventSinkWrapper.close (dart:async/stream_transformers.dart:21:11)
13 _WhereTypeStreamSink.close (package:rxdart/src/transformers/where_type.dart:19:31)
14 _SinkTransformerStreamSubscription._handleDone (dart:async/stream_transformers.dart:132:24)
15 _RootZone.runGuarded (dart:async/zone.dart:1582:10)
16 _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
17 _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
18 _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
19 _ForwardingStream._handleDone (dart:async/stream_pipe.dart:99:10)
20 _ForwardingStreamSubscription._handleDone (dart:async/stream_pipe.dart:161:13)
21 _RootZone.runGuarded (dart:async/zone.dart:1582:10)
22 _BufferingStreamSubscription._sendDone.sendDone (dart:async/stream_impl.dart:392:13)
23 _BufferingStreamSubscription._sendDone (dart:async/stream_impl.dart:402:7)
24 _BufferingStreamSubscription._close (dart:async/stream_impl.dart:291:7)
25 _SyncBroadcastStreamController._sendDone. (dart:async/broadcast_stream_controller.dart:399:22)
26 _BroadcastStreamController._forEachListener (dart:async/broadcast_stream_controller.dart:322:15)
27 _SyncBroadcastStreamController._sendDone (dart:async/broadcast_stream_controller.dart:398:7)
28 _BroadcastStreamController.close (dart:async/broadcast_stream_controller.dart:268:5)
29 StreamEventEmitter.close (package:events_emitter/emitters/stream_event_emitter.dart:117:30)
30 Peer._handleMessage (package:peerdart/src/peer.dart:200:26)
31 Peer._createServerConnection. (package:peerdart/src/peer.dart:121:7)
32 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
33 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
34 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
35 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
36 _MapStream._handleData (dart:async/stream_pipe.dart:218:10)
37 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
38 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
39 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
40 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
41 _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:63:11)
42 _EventSinkWrapper.add (dart:async/stream_transformers.dart:13:11)
43 _WhereTypeStreamSink.add (package:rxdart/src/transformers/where_type.dart:11:19)
44 _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
45 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
46 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
47 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
48 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
49 _WhereStream._handleData (dart:async/stream_pipe.dart:195:12)
50 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
51 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
52 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
53 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
54 _SyncBroadcastStreamController._sendData. (dart:async/broadcast_stream_controller.dart:385:20)
55 _BroadcastStreamController._forEachListener (dart:async/broadcast_stream_controller.dart:322:15)
56 _SyncBroadcastStreamController._sendData (dart:async/broadcast_stream_controller.dart:384:5)
57 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:244:5)
58 StreamEventEmitter.emitEvent (package:events_emitter/emitters/stream_event_emitter.dart:53:51)
59 StreamEventEmitter.emit (package:events_emitter/emitters/stream_event_emitter.dart:92:40)
60 Socket.start. (package:peerdart/src/socket.dart:54:7)
61 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
62 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
63 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
64 _ForwardingStreamSubscription._add (dart:async/stream_pipe.dart:123:11)
65 _HandleErrorStream._handleData (dart:async/stream_pipe.dart:253:10)
66 _ForwardingStreamSubscription._handleData (dart:async/stream_pipe.dart:153:13)
67 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
68 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
69 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
70 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:776:19)
71 _StreamController._add (dart:async/stream_controller.dart:650:7)
72 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
73 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
74 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
75 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:776:19)
76 _StreamController._add (dart:async/stream_controller.dart:650:7)
77 _StreamController.add (dart:async/stream_controller.dart:598:5)
78 new _WebSocketImpl._fromSocket. (dart:_http/websocket_impl.dart:1144:21)
79 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
80 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
81 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
82 _SinkTransformerStreamSubscription._add (dart:async/stream_transformers.dart:63:11)
83 _EventSinkWrapper.add (dart:async/stream_transformers.dart:13:11)
84 _WebSocketProtocolTransformer._messageFrameEnd (dart:_http/websocket_impl.dart:332:23)
85 _WebSocketProtocolTransformer.add (dart:_http/websocket_impl.dart:226:46)
86 _SinkTransformerStreamSubscription._handleData (dart:async/stream_transformers.dart:111:24)
87 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
88 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
89 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
90 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:776:19)
91 _StreamController._add (dart:async/stream_controller.dart:650:7)
92 _StreamController.add (dart:async/stream_controller.dart:598:5)
93 _Socket._onData (dart:io-patch/socket_patch.dart:2381:41)
94 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
95 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
96 _BufferingStreamSubscription._add (dart:async/stream_impl.dart:271:7)
97 _SyncStreamControllerDispatch._sendData (dart:async/stream_controller.dart:776:19)
98 _StreamController._add (dart:async/stream_controller.dart:650:7)
99 _StreamController.add (dart:async/stream_controller.dart:598:5)
100 _RawSecureSocket._sendReadEvent (dart:io/secure_socket.dart:1114:19)
101 Timer._createTimer. (dart:async-patch/timer_patch.dart:18:15)
102 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
103 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
104 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:189:12)
xml:Ringing... Call from Prabhu
OnMediaSourceRemoved: 0
OnMediaSourceAdded: 0
sources: 1
OnMediaSourceThumbnailChanged: 0
OnMediaSourceThumbnailChanged: 0
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: Cannot add new events after calling close
0 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:243:24)
1 StreamEventEmitter.emitEvent (package:events_emitter/emitters/stream_event_emitter.dart:53:51)
2 StreamEventEmitter.emit (package:events_emitter/emitters/stream_event_emitter.dart:92:40)
3 Negotiator._setupListeners. (package:peerdart/src/negotiator.dart:263:18)
4 RTCPeerConnectionNative.eventListener (package:flutter_webrtc/src/native/rtc_peerconnection_impl.dart:84:31)
5 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
6 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
7 _DelayedData.perform (dart:async/stream_impl.dart:515:14)
8 _PendingEvents.handleNext (dart:async/stream_impl.dart:620:11)
9 _PendingEvents.schedule. (dart:async/stream_impl.dart:591:7)
10 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
11 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Bad state: Cannot add new events after calling close
0 _BroadcastStreamController.add (dart:async/broadcast_stream_controller.dart:243:24)
1 StreamEventEmitter.emitEvent (package:events_emitter/emitters/stream_event_emitter.dart:53:51)
2 StreamEventEmitter.emit (package:events_emitter/emitters/stream_event_emitter.dart:92:40)
3 MediaConnection.addStream (package:peerdart/src/mediaconnection.dart:32:11)
4 Negotiator._addStreamToMediaConnection (package:peerdart/src/negotiator.dart:328:21)
5 Negotiator._setupListeners. (package:peerdart/src/negotiator.dart:297:9)
6 RTCPeerConnectionNative.eventListener (package:flutter_webrtc/src/native/rtc_peerconnection_impl.dart:181:18)
7 _RootZone.runUnaryGuarded (dart:async/zone.dart:1594:10)
8 _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:339:11)
9 _DelayedData.perform (dart:async/stream_impl.dart:515:14)
10 _PendingEvents.handleNext (dart:async/stream_impl.dart:620:11)
11 _PendingEvents.schedule. (dart:async/stream_impl.dart:591:7)
12 _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
13 _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)