flutterjanus / flutter_janus_client

A plugin that allows the flutter app to communicate with a Janus server using different transport mechanisms, such as WebSocket and HTTP(rest). It features a developer-friendly api to interact with various WebRTC Janus Plugins. Hence, it can be considered as a swiss-knife for WebRTC solutions.
MIT License
131 stars 76 forks source link

peerConnectionAddStreamFailed, peerConnection is null #5

Closed alsiPanda closed 3 years ago

alsiPanda commented 3 years ago

Hi @shivanshtalwar0 , I am getting the following error when running the videocall and videoRoom example on android device. However on making the call, the call doesn't reach the other device. This is the error I am getting :

videocall:

2020-09-24 06:07:22.825 30773-30845/social.openbook.app.dev E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(171)] Unhandled Exception: PlatformException(peerConnectionAddStreamFailed, peerConnectionAddStream() peerConnection is null, null, null)

0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:582:7)

1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:18)

#2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:332:12) #3 RTCPeerConnection.addStream (package:flutter_webrtc/src/rtc_peerconnection.dart:243:20) #4 Plugin.initializeMediaDevices (package:janus_client/Plugin.dart:107:24) #5 _VideoCallExampleState.makeCall (package:Okuna/pages/home/pages/channel_chat/janus_video_call.dart:51:24) #6 _VideoCallExampleState.makeCallDialog.. (package:Okuna/pages/home/pages/channel_chat/janus_video_call.dart:133:21) #7 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:993:19) #8 _InkResponseState.build. (package:flutter/src/material/ink_well.dart:1111:38) #9 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:183:24) #10 TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:598:11) #11 BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:287:5) #12 BaseTapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:222:7) #13 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:476:9) #14 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:77:12) #15 PointerRouter._dispatchEventToRoutes. (package:flutter/src/gestures/pointer_router.dart:122:9) #16 _LinkedHashMapMixin.forEach (dart:collection-patch/compact_hash.dart:377:8) #17 PointerRouter._dispatchEventToRoutes (package:flutter/src/gestures/pointer_router.dart:120:18) #18 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:106:7) #19 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:358:19) #20 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:338:22) #21 RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:267:11) #22 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:295:7) #23 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:240:7) #24 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:213:7) #25 _rootRunUnary (dart:async/zone.dart:1206:13) #26 _CustomZone.runUnary (dart:async/zone.dart:1100:19) #27 _CustomZone.runUnaryGuarded (dart:async/zone.dart:1005:7) #28 _invoke1 (dart:ui/hooks.dart:265:10) #29 _dispatchPointerDataPacket (dart:ui/hooks.dart:174:5) 2020-09-24 06:07:22.829 30773-30845/social.openbook.app.dev E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(171)] Unhandled Exception: Unable to RTCPeerConnection::createOffer: peerConnection is null #0 RTCPeerConnection.createOffer (package:flutter_webrtc/src/rtc_peerconnection.dart:220:7) #1 Plugin.createOffer (package:janus_client/Plugin.dart:238:32) #2 _VideoCallExampleState.makeCall (package:Okuna/pages/home/pages/channel_chat/janus_video_call.dart:61:60) #3 _rootRunUnary (dart:async/zone.dart:1198:47) #4 _CustomZone.runUnary (dart:async/zone.dart:1100:19) #5 _FutureListener.handleValue (dart:async/future_impl.dart:143:18) #6 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45) #7 Future._propagateToListeners (dart:async/future_impl.dart:725:32) #8 Future._completeWithValue (dart:async/future_impl.dart:529:5) #9 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15) #10 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13) #11 Plugin.initializeMediaDevices (package:janus_client/Plugin.dart) #12 _rootRunUnary (dart:async/zone.dart:1198:47) #13 _CustomZone.runUnary (dart:async/zone.dart:1100:19) #14 _FutureListener.handleValue (dart:async/future_impl.dart:143:18) #15 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45) #16 Future._propagateToListeners (dart:async/future_impl.dart:725:32) #17 Future._completeWithValue (dart:async/future_impl.dart:529:5) #18 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15) #19 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13) #20 MediaDevices.getUserMedia (package:flutter_webrtc/src/get_user_media.dart) #21 _rootRunUnary (dart:async/zone.dart:1198:47) #22 _CustomZone.runUnary (dart:async/zone.dart:1100:19) #23 _FutureListener.handleValue (dart:async/future_impl.dart:143:18) #24 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45) #25 Future._propagateToListeners (dart:async/future_impl.dart:725:32) #26 Future._completeWithValue (dart:async/future_impl.dart:529:5) #27 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15) #28 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13) #29 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart) #30 _rootRunUnary (dart:async/zone.dart:1198:47) #31 _CustomZone.runUnary (dart:async/zone.dart:1100:19) #32 _FutureListener.handleValue (dart:async/future_impl.dart:143:18) #33 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45) #34 Future._propagateToListeners (dart:async/future_impl.dart:725:32) #35 Future._completeWithValue (dart:async/future_impl.dart:529:5) #36 Future._asyncCompleteWithValue. (dart:async/future_impl.dart:567:7) #37 _rootRun (dart:async/zone.dart:1190:13) #38 _CustomZone.run (dart:async/zone.dart:1093:19) #39 _CustomZone.runGuarded (dart:async/zone.dart:997:7) #40 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1037:23) #41 _microtaskLoop (dart:async/schedule_microtask.dart:41:21) #42 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)

videoroom:

2020-09-24 06:53:19.461 6265-6326/social.openbook.app.dev E/flutter: [ERROR:flutter/lib/ui/ui_dart_state.cc(171)] Unhandled Exception: PlatformException(peerConnectionAddStreamFailed, peerConnectionAddStream() peerConnection is null, null, null)

0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:582:7)

1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:159:18)

#2 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:332:12) #3 RTCPeerConnection.addStream (package:flutter_webrtc/src/rtc_peerconnection.dart:243:20) #4 Plugin.initializeMediaDevices (package:janus_client/Plugin.dart:107:24) #5 _VideoRoomState.initPlatformState... (package:Okuna/pages/home/pages/channel_chat/group_video.dart:130:49) #6 JanusClient.attach (package:janus_client/janus_client.dart:364:25) #7 _rootRunUnary (dart:async/zone.dart:1198:47) #8 _CustomZone.runUnary (dart:async/zone.dart:1100:19) #9 _FutureListener.handleValue (dart:async/future_impl.dart:143:18) #10 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45) #11 Future._propagateToListeners (dart:async/future_impl.dart:725:32) #12 Future._completeWithValue (dart:async/future_impl.dart:529:5) #13 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15) #14 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13) #15 JanusClient._postRestClient (package:janus_client/janus_client.dart) #16 _rootRunUnary (dart:async/zone.dart:1198:47) #17 _CustomZone.runUnary (dart:async/zone.dart:1100:19) #18 _FutureListener.handleValue (dart:async/future_impl.dart:143:18) #19 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45) #20 Future._propagateToListeners (dart:async/future_impl.dart:725:32) #21 Future._completeWithValue (dart:async/future_impl.dart:529:5) #22 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15) #23 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13) #24 _withClient (package:http/http.dart) #25 _rootRunUnary (dart:async/zone.dart:1198:47) #26 _CustomZone.runUnary (dart:async/zone.dart:1100:19) #27 _FutureListener.handleValue (dart:async/future_impl.dart:143:18) #28 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45) #29 Future._propagateToListeners (dart:async/future_impl.dart:725:32) #30 Future._completeWithValue (dart:async/future_impl.dart:529:5) #31 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15) #32 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13) #33 Response.fromStream (package:http/src/response.dart) #34 _rootRunUnary (dart:async/zone.dart:1198:47) #35 _CustomZone.runUnary (dart:async/zone.dart:1100:19) #36 _FutureListener.handleValue (dart:async/future_impl.dart:143:18) #37 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45) #38 Future._propagateToListeners (dart:async/future_impl.dart:725:32) #39 Future._completeWithValue (dart:async/future_impl.dart:529:5) #40 Future._asyncCompleteWithValue. (dart:async/future_impl.dart:567:7) #41 _rootRun (dart:async/zone.dart:1190:13) #42 _CustomZone.run (dart:async/zone.dart:1093:19) #43 _CustomZone.runGuarded (dart:async/zone.dart:997:7) #44 _CustomZone.bindCallbackGuarded. (dart:async/zone.dart:1037:23) #45 _microtaskLoop (dart:async/schedule_microtask.dart:41:21) #46 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5)

I think it might be related to the fact that jsep is null as seen from here: print('publisheronmsg : $msg, jsep : $jsep');

publisheronmsg : {videoroom: joined, room: 1234, description: Demo Room, id: 5268502155221207, private_id: 2581568118, publishers: []}, jsep : null

Can you please help out with this ?

shivanshtalwar0 commented 3 years ago

@alsiPanda can you please share your code or any modifications that you did to current code? Also have you tried it on some other android device? Seems like flutter webrtc issue

alsiPanda commented 3 years ago

There are a few code modification I did. 1- automate the name, so I don't have to type everytime. The functions are all the same. 2- the Navigator.pop() in the example code was causing some problem so I fixed that. To be precise in the dialog. It was popping the wrong context. 3- the server address in janus initialisation I have changed. I am using your janusdeploy docker image, hosted on Google cloud. So I have removed the following auth as well. I presume that shouldn't affect peerConnection.

As for trying it, I have used it on two very different android devices. Both show the same problem.

Any specific place where I should look at?

shivanshtalwar0 commented 3 years ago

Okay! Yes auth credentials are optional if authentication is not set up in configuration or while running janus, also is your janus server running fine with stun server added in configuration file? Please try server that i have been using in example and let me know if works then we can be sure that something isn't right on your janus deployment

On Thu, 24 Sep, 2020, 8:52 am alsiPanda, notifications@github.com wrote:

There are a few code modification I did. 1- automate the name, so I don't have to type everytime. The functions are all the same. 2- the Navigator.pop() in the example code was causing some problem so I fixed that. To be precise in the dialog. It was popping the wrong context. 3- the server address in janus initialisation I have changed. I am using your janusdeploy docker image, hosted on Google cloud. So I have removed the following auth as well. I presume that shouldn't affect peerConnection.

As for trying it, I have used it on two very different android devices. Both show the same problem.

Any specific place where I should look at?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/shivanshtalwar0/flutter_janus_client/issues/5#issuecomment-698087782, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGLGDV7Q7C4VJSVO7PBLBO3SHK3P7ANCNFSM4RXVSOFA .

alsiPanda commented 3 years ago

My Server seems to be running fine, the api responds when registering, hanging up, joining room. As for stun servers, I am using Google stun servers. Both in the flutter code and internally in the Janus config file. I will try using the onemandev server used in the example and let you know.

alsiPanda commented 3 years ago

@shivanshtalwar0 , good news is the peer connection error is gone. Bad news is the remoteRenderer is still blank. The peer connection null error was solved by using the TURN server originally in the code, which I had accidentally replaced by a google stun server. The error was gone after. So I went to the janus.jcfg and added the same TURN server . But remote renderer is blank and there is no error. Can you post your janus.jcfg file ?

shivanshtalwar0 commented 3 years ago

You can find janus.jcfg on my official docker image, in directory /opt/janus/etc/janus.jcfg after running container

sasikumarramans commented 1 year ago

Hi @shivanshtalwar0 I am trying to disable the video in flutter by using api {"request":"configure","video":false,"audio":true} but this is not working I tried with createoffer also Please anyone help on this

shivanshtalwar0 commented 1 year ago

When you say video what are you referring to? If you talking about video being captured from your device you need to provide your own mediacontraints in initializeMediaDevice method doing that will not capture it so will not be sent