ConnectyCube / connectycube-reactnative-samples

Chat and Video Chat code samples for React Native, ConnectyCube
https://connectycube.com
Apache License 2.0
125 stars 111 forks source link

Most of the time video call works fine but randomly it not connected #221

Closed Sandeep145XamRN closed 3 years ago

Sandeep145XamRN commented 3 years ago

I am using connectycube library for implementing video call functionality in my app. Sometimes it works fine without any error but sometimes does not connect.

Code details:=> ReactNative: 0.63.2 Connectycube: 3.7.2

Find below the logs for better understanding:

invokeCallbackAndReturnFlushedQueue@[native code] [Thu Apr 01 2021 14:22:29.760] LOG [Response][4] {"session": {"application_id": 3448, "created_at": "2021-04-01T08:52:28Z", "id": 39965557, "nonce": 5821, "token": "377f34ad6af3b2097d27b53465efb26c31000d78", "ts": 1617267147, "updated_at": "2021-04-01T08:52:28Z", "user": {"avatar": null, "blob_id": null, "created_at": "2021-01-12T04:34:11Z", "custom_data": null, "email": "kitti@yopmail.com", "external_user_id": null, "facebook_id": null, "full_name": "Hello Kitti", "id": 3254590, "last_request_at": "2021-04-01T08:52:28Z", "login": null, "phone": null, "twitter_id": null, "updated_at": "2021-04-01T08:52:28Z", "user_tags": null, "website": null}, "user_id": 3254590}} [Thu Apr 01 2021 14:22:29.760] LOG [Chat] Connect with parameters {"password": "Mind@123", "userId": 3254590} [Thu Apr 01 2021 14:22:29.770] LOG [Chat] status connecting wss://chat.connectycube.com:5291 [Thu Apr 01 2021 14:22:29.508] WARN VirtualizedLists should never be nested inside plain ScrollViews with the same orientation - use another VirtualizedList-backed container instead. VirtualizedList@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:62698:22 FlatList@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:62172:36 RCTView StyledNativeComponent@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:128084:36 RCTView StyledNativeComponent@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:128084:36 RCTScrollContentView RCTScrollView ScrollView@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:64786:36 ScrollView StyledNativeComponent@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:128084:36 RCTView ImageBackground@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:67860:22 StyledNativeComponent@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:128084:36 RCTView AnimatedComponent@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:61821:24 AnimatedComponentWrapper SafeAreaView@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:130705:36 StyledNativeComponent@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:128084:36 PatientHomeScreen@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:236385:36 ConnectFunction@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:194824:43 StaticContainer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:105520:17 EnsureSingleNavigator@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:104185:24 SceneView@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:105411:22 RCTView SceneContent@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:244849:25 RCTView RCTView ResourceSavingScene@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:245128:36 RCTView ScreenContainer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:113631:36 RCTView SafeAreaProviderCompat@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:245059:24 BottomTabView@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:244879:36 BottomTabNavigator@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:244767:32 TabNavigator@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:100766:44 StaticContainer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:105520:17 EnsureSingleNavigator@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:104185:24 SceneView@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:105411:22 RCTView RCTView RCTView CardSheet@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:117810:23 RCTView AnimatedComponent@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:61821:24 AnimatedComponentWrapper PanGestureHandler@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:110342:38 PanGestureHandler@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:109513:34 RCTView AnimatedComponent@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:61821:24 AnimatedComponentWrapper RCTView Card@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:115241:36 CardContainer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:114926:22 RCTView MaybeScreen@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:113380:24 RCTView MaybeScreenContainer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:113349:23 CardStack@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:112879:36 KeyboardManager@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:117979:36 SafeAreaProviderCompat@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:118422:24 RCTView StackView@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:108751:36 StackNavigator@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:102416:32 RCTView AnimatedComponent(View)@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:233702:38 PatientDrawerScreens@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:100667:21 StaticContainer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:105520:17 EnsureSingleNavigator@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:104185:24 SceneView@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:105411:22 RCTView RCTView ResourceSavingScene@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:229084:36 RCTView ScreenContainer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:113631:36 RCTView RCTView AnimatedComponent(View)@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:233702:38 RCTView AnimatedComponent(View)@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:233702:38 PanGestureHandler@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:110342:38 PanGestureHandler@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:228953:34 DrawerView@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:229739:36 SafeAreaProviderCompat@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:229015:24 RCTView DrawerView@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:228656:22 DrawerNavigator@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:228563:32 RCTView PatientDrawerNavigator@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:100578:41 StaticContainer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:105520:17 EnsureSingleNavigator@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:104185:24 SceneView@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:105411:22 RCTView RCTView RCTView CardSheet@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:117810:23 RCTView AnimatedComponent@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:61821:24 AnimatedComponentWrapper PanGestureHandler@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:110342:38 PanGestureHandler@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:109513:34 RCTView AnimatedComponent@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:61821:24 AnimatedComponentWrapper RCTView Card@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:115241:36 CardContainer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:114926:22 RCTView MaybeScreen@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:113380:24 RCTView MaybeScreenContainer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:113349:23 CardStack@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:112879:36 KeyboardManager@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:117979:36 SafeAreaProviderCompat@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:118422:24 RCTView StackView@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:108751:36 StackNavigator@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:102416:32 Navigator EnsureSingleNavigator@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:104185:24 BaseNavigationContainer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:103853:28 ThemeProvider@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:107906:21 NavigationContainer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:107812:26 NetworkProvider@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:337883:36 Provider@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:194412:21 RNCSafeAreaProvider SafeAreaProvider@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:109285:24 App@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:100003:36 RCTView RCTView AppContainer@http://localhost:8081/index.bundle?platform=ios&dev=true&minify=false:68598:22 [Thu Apr 01 2021 14:22:30.852] LOG [Chat] status connect [Thu Apr 01 2021 14:22:30.854] LOG [Chat] CONNECTING [Thu Apr 01 2021 14:22:30.854] LOG [Chat] status opening [Thu Apr 01 2021 14:22:30.855] LOG [Chat] SENT: [Thu Apr 01 2021 14:22:31.463] LOG [Chat] RECV: [Thu Apr 01 2021 14:22:31.464] LOG [Chat] status open [Thu Apr 01 2021 14:22:31.466] LOG [Chat] RECV: PLAINANONYMOUSPLAIN_FAST</stream:features> [Thu Apr 01 2021 14:22:31.466] LOG [Chat] SENT: ADMyNTQ1OTAtMzQ0OABNaW5kQDEyMw== [Thu Apr 01 2021 14:22:31.969] LOG [Chat] RECV: [Thu Apr 01 2021 14:22:31.970] LOG [Chat] status opening [Thu Apr 01 2021 14:22:31.971] LOG [Chat] SENT: [Thu Apr 01 2021 14:22:32.525] LOG [Chat] RECV: [Thu Apr 01 2021 14:22:32.526] LOG [Chat] status open [Thu Apr 01 2021 14:22:32.529] LOG [Chat] RECV: </stream:features> [Thu Apr 01 2021 14:22:32.530] LOG [Chat] SENT: [Thu Apr 01 2021 14:22:33.138] LOG [Chat] RECV: jid>3254590-3448@chat.connectycube.com/1204607085-chat-377071</jid [Thu Apr 01 2021 14:22:33.139] LOG [Chat] SENT: [Thu Apr 01 2021 14:22:33.140] LOG [Chat] status online 3254590-3448@chat.connectycube.com/1204607085-chat-377071 [Thu Apr 01 2021 14:22:33.140] LOG [Chat] ONLINE [Thu Apr 01 2021 14:22:33.141] LOG [Chat] CONNECTED [Thu Apr 01 2021 14:22:33.142] LOG [Chat] SENT: [Thu Apr 01 2021 14:22:33.142] LOG [Chat] SENT: [Thu Apr 01 2021 14:22:33.645] LOG [Chat] RECV: [Thu Apr 01 2021 14:22:33.923] LOG [Chat] RECV: [Thu Apr 01 2021 14:22:33.924] LOG [Chat] RECV: [Thu Apr 01 2021 14:22:33.925] LOG [Chat] RECV: [Thu Apr 01 2021 14:22:33.926] LOG [Chat] RECV: [Thu Apr 01 2021 14:22:34.318] LOG [Chat] RECV: [Thu Apr 01 2021 14:22:34.338] LOG [Chat] SENT: </stream:error> [Thu Apr 01 2021 14:22:34.342] LOG [Chat] ERROR: [XMLError: must be a child.] [Thu Apr 01 2021 14:22:34.365] LOG [Chat] SENT: [Thu Apr 01 2021 14:22:34.373] LOG [Chat] status disconnecting [Thu Apr 01 2021 14:22:34.386] LOG [Chat] RECV: [Thu Apr 01 2021 14:22:34.390] LOG [Chat] SENT: </stream:error> [Thu Apr 01 2021 14:22:34.392] LOG [Chat] ERROR: [XMLError: must be a child.] [Thu Apr 01 2021 14:22:34.400] LOG [Chat] SENT: [Thu Apr 01 2021 14:22:34.402] LOG [Chat] status disconnecting [Thu Apr 01 2021 14:22:35.120] LOG [Chat] RECV: Feature not supported yet.</stream:error> [Thu Apr 01 2021 14:22:35.121] ERROR [TypeError: null is not an object (evaluating 'this.parser.write')] [Thu Apr 01 2021 14:22:35.190] LOG [Chat] RECV: [Thu Apr 01 2021 14:22:35.191] LOG [Chat] SENT: [Thu Apr 01 2021 14:22:35.192] LOG [Chat] RECV: [Thu Apr 01 2021 14:22:35.193] LOG [Chat] SENT: [Thu Apr 01 2021 14:22:35.341] LOG [Chat] ERROR: [Error: WebSocket ECONNERROR wss://chat.connectycube.com:5291] [Thu Apr 01 2021 14:22:35.347] LOG [Chat] status disconnect [object Object] [Thu Apr 01 2021 14:22:35.349] LOG [Chat] DISCONNECTED [Thu Apr 01 2021 14:22:35.350] LOG [Chat] Connect with parameters {"password": "Mind@123", "userId": 3254590} [Thu Apr 01 2021 14:22:35.483] LOG [Chat] RECV: Feature not supported yet.</stream:error> [Thu Apr 01 2021 14:22:35.484] ERROR [TypeError: null is not an object (evaluating 'this.parser.write')] [Thu Apr 01 2021 14:22:35.523] LOG [Chat] RECV: [Thu Apr 01 2021 14:22:35.523] ERROR [TypeError: null is not an object (evaluating 'this.parser.write')] [Thu Apr 01 2021 14:22:35.544] LOG [Chat] ERROR: [Error: WebSocket ECONNERROR wss://chat.connectycube.com:5291] [Thu Apr 01 2021 14:22:35.545] LOG [Chat] status disconnect [object Object] [Thu Apr 01 2021 14:22:35.563] LOG [Chat] DISCONNECTED

tajinder007 commented 3 years ago

Facing same error!

igogna commented 3 years ago

@Sandeep145XamRN have you solved it ??? I am also facing the same issue

DaveLomber commented 3 years ago

@igogna @tajinderseasia @Sandeep145XamRN could you please provide more info around the issue

Sandeep145XamRN commented 3 years ago

I'm facing this problem very first time when I try to receive call on Android device(Android version 7.0), onCallListener not calling when I trying 2nd time then call connects. When I killed app and re-open it, then the same problem comes again.

ccvlad commented 3 years ago

@Sandeep145XamRN

From the log you have provided:

[Thu Apr 01 2021 14:22:31.466] LOG [Chat] SENT: ADMyNTQ1OTAtMzQ0OABNaW5kQDEyMw==
[Thu Apr 01 2021 14:22:31.969] LOG [Chat] RECV:
[Thu Apr 01 2021 14:22:31.970] LOG [Chat] status opening
[Thu Apr 01 2021 14:22:31.971] LOG [Chat] SENT:
[Thu Apr 01 2021 14:22:32.525] LOG [Chat] RECV:
Sandeep145XamRN commented 3 years ago

@ccvlad I think it is encrypted forms of ConnectyCube app id, user id and user password, but not sure about that. We are only using ConnectyCube video call service in our project not other part(chat).

please find new log:

[Mon Apr 05 2021 15:44:36.970] LOG total props {"onBlur": [Function onBlur], "onChangeText": [Function onChangeText], "onFocus": [Function onFocus], "onSelectMedia": [Function onSelectMedia], "onSendPressed": [Function onSendPressed], "onSizeChange": [Function onSizeChange], "text": ""} [Mon Apr 05 2021 15:44:36.362] LOG [Chat] status connect [Mon Apr 05 2021 15:44:36.363] LOG [Chat] CONNECTING [Mon Apr 05 2021 15:44:36.364] LOG [Chat] status opening [Mon Apr 05 2021 15:44:36.374] LOG [Chat] SENT: [Mon Apr 05 2021 15:44:37.210] LOG [Chat] RECV: [Mon Apr 05 2021 15:44:37.220] LOG [Chat] status open [Mon Apr 05 2021 15:44:37.450] LOG [Chat] RECV: PLAINANONYMOUSPLAIN_FAST</stream:features> [Mon Apr 05 2021 15:44:37.470] LOG [Chat] SENT: ADMyNTQ1OTAtMzQ0OABNaW5kQDEyMw== [Mon Apr 05 2021 15:44:37.686] LOG [Chat] RECV: [Mon Apr 05 2021 15:44:37.687] LOG [Chat] status opening [Mon Apr 05 2021 15:44:37.693] LOG [Chat] SENT: [Mon Apr 05 2021 15:44:38.262] LOG [Chat] RECV: [Mon Apr 05 2021 15:44:38.264] LOG [Chat] status open [Mon Apr 05 2021 15:44:38.273] LOG [Chat] RECV: </stream:features>

Sandeep145XamRN commented 3 years ago

@ccvlad any update on this, we have spent a lot of time on this issue. Is this issue not being reproduced at your end? I'm also facing this issue with 3.8.0 version, when trying to receive call from iOS device to Android device. Help would be appreciated, we await your response.

ccvlad commented 3 years ago

The log LOG [Chat] ERROR: [XMLError: must be a child.] means that you sent some wrong data via chat. As the result chat goes disconnected - the log LOG [Chat] DISCONNECTED is about. The log ERROR [TypeError: null is not an object (evaluating 'this.parser.write')] says that you're trying to send some data via chat, but it was disconnected.

I noticed about LOG [Chat] SENT: ADMyNTQ1OTAtMzQ0OABNaW5kQDEyMw==, cause chat message should be look like XML, but seems it is a string.

Can I see your code if it possible?

Sandeep145XamRN commented 3 years ago

I'm using below code to start a call, but problem is coming at receiver end and the call is not connecting for the first time. The first time listener does not work.

`_setUpListeners() { ConnectyCube.videochat.onCallListener = this._onCallListener; ConnectyCube.videochat.onAcceptCallListener = this._onAcceptCallListener; ConnectyCube.videochat.onRejectCallListener = this._onRejectCallListener; ConnectyCube.videochat.onStopCallListener = this._onStopCallListener; ConnectyCube.videochat.onUserNotAnswerListener = this._onUserNotAnswerListener; ConnectyCube.videochat.onRemoteStreamListener = this._onRemoteStreamListener; }

//to start call startCall = async () => { const { selectedUsersIds, closeSelect, initRemoteStreams, setLocalStream, senderId, recieverId } = this.props; //connect ConnectyCube.createSession() .then((session) => { console.warn('session is', session) }) .catch((error) => { console.warn('session error', error) }); // ConnectyCube.chat.disconnect(); ConnectyCube.chat.connect() //video call notification API if (this.isConnected()) { // this.showDialog() NotificationApi({ "receiver_id": recieverId, "sender_id": senderId }, response => this.handleNotificationResponse(response)); } else { this.showToastAlert(STRINGS.NO_INTERNET_CONNECTION) } if (selectedUsersIds.length === 0) { this.showToast('Select at less one user to start Videocall'); } else { closeSelect(); initRemoteStreams(selectedUsersIds); ConnectycubeCallServices.startCall(selectedUsersIds).then(setLocalStream); } };`

ccvlad commented 3 years ago

//to start call startCall = async () => { const { selectedUsersIds, closeSelect, initRemoteStreams, setLocalStream, senderId, recieverId } = this.props; //connect ConnectyCube.createSession() .then((session) => { console.warn('session is', session) }) .catch((error) => { console.warn('session error', error) }); // ConnectyCube.chat.disconnect(); ConnectyCube.chat.connect() //video call notification API if (this.isConnected()) { // this.showDialog() NotificationApi({ "receiver_id": recieverId, "sender_id": senderId }, response => this.handleNotificationResponse(response)); } else { this.showToastAlert(STRINGS.NO_INTERNET_CONNECTION) } if (selectedUsersIds.length === 0) { this.showToast('Select at less one user to start Videocall'); } else { closeSelect(); initRemoteStreams(selectedUsersIds); ConnectycubeCallServices.startCall(selectedUsersIds).then(setLocalStream); } };`

The code snippet won't work. There isn't order: await ConnectyCube.createSession(userCredentials) > await ConnectyCube.chat.connect({userId/email, password}) > const callSession = ConnectyCube.videochat.createNewSession(calleesIds, sessionType, additionalOptions) > callSession.call(extension)

Sandeep145XamRN commented 3 years ago

@ccvlad thanks for your help, I implemented the code as you mentioned. Our problem has become very solvent, but there is just one case left, when I trying to receive video call from iOS device to iOS device, call does not connect at first attempt, but connects at second try. Am I doing something wrong when the call is coming?

_onCallListener = (session, extension) => { ConnectycubeCallServices.processOnCallListener(session) .then(() => { this.showInomingCallModal(session) }) .catch(() => { this.hideInomingCallModal }); };

ConnectycubeCallServices class as:

processOnCallListener(session) { return new Promise((resolve, reject) => { if (session.initiatorID === session.currentUserID) { reject(); } if (this._session) { this.rejectCall(session, { busy: true }); reject(); } this.playSound('incoming'); resolve(); }); }

ccvlad commented 3 years ago

Could you show the log?