QuickBlox / quickblox-javascript-sdk

JavaScript SDK of QuickBlox cloud backend platform
Other
105 stars 217 forks source link

Uncaught TypeError: Cannot create property 'onRemoteStreamListener' on boolean 'false' #411

Open tarungomile opened 3 years ago

tarungomile commented 3 years ago

Environment details Platform: React JS SDK: Javascript SDK

(Operating system, browser information, SDK version) OS: MacOs

Did this work before? It is working on my local environment when i run 'npm start' it works as expected but when I migrate the build to server/hosting it is giving me this error

Screenshot 2021-03-24 at 3 35 58 PM

Logs [QBChat] Status.CONNECTING (Chat Protocol - BOSH action.ts:68 Uncaught TypeError: Cannot create property 'onRemoteStreamListener' on boolean 'false' at e.value (videoCallStore.js:82) at ve (action.ts:65) at e.QbInit (action.ts:46) at new e (videoCallStore.js:16) at Module.656 (videoCallStore.js:251) at a ((index):1) at t ((index):1) at Array.r [as push] ((index):1) at main.85737f77.chunk.js:1 value @ videoCallStore.js:82 ve @ action.ts:65 QbInit @ action.ts:46 e @ videoCallStore.js:16 656 @ videoCallStore.js:251 a @ (index):1 t @ (index):1 r @ (index):1 (anonymous) @ main.85737f77.chunk.js:1 quickblox.js:54153 [Response][1] {api_endpoint: "https://api.quickblox.com", chat_endpoint: "chat.quickblox.com", turnserver_endpoint: "turn.quickblox.com"} quickblox.js:54153 [QBChat] RECV: <stream:features xmlns=​"jabber:​client">​…​</stream:features>​ quickblox.js:54153 [QBChat] SENT: <auth xmlns=​"urn:​ietf:​params:​xml:​ns:​xmpp-sasl" mechanism=​"PLAIN">​ADEyNzA4Nzg1MS04OTMxNgBtZW50ZWVyZQ==​​

Code which I am using QbInit() { if(localStorage.getItem('userID')) { QB.init(this.APPLICATION_ID, this.AUTH_KEY, this.AUTH_SECRET, this.ACCOUNT_KEY, this.CONFIG);

        if(!localStorage.getItem('QUICK_USER_TOKEN')) {   
            var params = { login: localStorage.getItem('userID'), password: 'menteere' };  
            QB.createSession(params, function(error, result) {
                // callback function
                if(result != null) {
                    localStorage.setItem('QUICK_CREATE_SESSION_RESPONSE', result);
                    localStorage.setItem('QUICK_USER_TOKEN', result.token);
                }
            });
        }

            QB.chat.connect({ userId: localStorage.getItem('quickbloxId'), password: 'menteere' }, function (err, roster) {
                //_this.makeCall();
            });

            QB.webrtc.onUserNotAnswerListener = function(session, userId) {
                videoCallStore.callStatus = 'CALL_NOT_ANSWERED';
            };

            QB.webrtc.onRemoteStreamListener = function(session, userID, remoteStream) {
                // attach the remote stream to DOM element
                session.attachMediaStream("frontVideoElem", remoteStream);
                videoCallStore.callStatus = 'STREAM_STARTED';
            };

            QB.webrtc.onAcceptCallListener = function(session, userId, extension) {
                videoCallStore.callStatus = 'CALL_ACCEPTED';
            };

            QB.webrtc.onRejectCallListener = function(session, userId, extension) {
                videoCallStore.callStatus = 'CALL_REJECTED';
            };

            QB.webrtc.onStopCallListener = function(session, userId, extension) {
                videoCallStore.callStatus = 'CALL_ENDED';
            };

            /* QB.webrtc.onSessionCloseListener = function(session) {
                videoCallStore.callStatus = 'CALL_SESSION_CLOSED';
            }; */

            var _this = this;
            QB.webrtc.onCallListener = function(session, extension) {
                _this.showCallPop = true;
                videoCallStore.callSession = session;
            };

            QB.webrtc.onSessionConnectionStateChangedListener = function(session, userId, connectionState) { 
                switch(connectionState) {
                    case 1:
                        videoCallStore.callStatus = 'CALL_IN_SESSION_CONNECTING';
                    break;
                    case 2:
                        videoCallStore.callStatus = 'CALL_IN_SESSION_CONNECTED';
                    break;
                    case 3:
                        videoCallStore.callStatus = 'CALL_IN_SESSION_CLOSED';
                    break;
                    case 4:
                        videoCallStore.callStatus = 'CALL_IN_SESSION_FAILED';
                    break;
                    case 5:
                        videoCallStore.callStatus = 'CALL_IN_SESSION_COMPLETED';
                    break;
                }
            }

    }
}

It can be because of registering domain to somewhere in QuickBlox settings but can't see this kind of step in documentation as well as in Quickblox Admin Portal.

Please help!!

ghost commented 3 years ago

Hi @tarungomile , As the error says - you're trying to assign a function to false. This can happen if you're trying to assign some handler to webrtc module while QB JS SDK is not yet initialized or if WebRTC is not available. In such case QB.webrtc will have value false.