diff --git a/bigbluebutton-html5/imports/ui/components/video-provider/component.jsx b/bigbluebutton-html5/imports/ui/components/video-provider/component.jsx
index 0dbe52c672c6b19243c30facbf2d506e994245ef..d2ef0306a02da5e2b7fd39ae08466c443425ec95 100755
--- a/bigbluebutton-html5/imports/ui/components/video-provider/component.jsx
+++ b/bigbluebutton-html5/imports/ui/components/video-provider/component.jsx
@@ -798,10 +798,9 @@ class VideoProvider extends Component {
   }
 
   _getOnIceCandidateCallback(id, shareWebcam) {
-    const peer = this.webRtcPeers[id];
-    const role = shareWebcam ? 'share' : 'viewer';
-
     return (candidate) => {
+      const peer = this.webRtcPeers[id];
+      const role = shareWebcam ? 'share' : 'viewer';
       // Setup a timeout only when the first candidate is generated and if the peer wasn't
       // marked as started already (which is done on handlePlayStart after
       // it was verified that media could circle through the server)