PlainHtml Content

Ask questions about the JavaScript API here

PlainHtml Content

Postby bharadwaj » Sat Nov 03, 2012 1:03 am

Hey OpenTok,
I am Taking a plain html and generating session and token from opentok server side libraries and passing these three values as static content to html.

But Session is connected and sessionConnectedHandler(event) is not firing and showing the message dialog.
The Connection timeout. Make Sure that You have allowed this page in FlashPlayer Global Settings Manager.

But i have added my file location and started my browser even then same error;
Please get me out of it:
Here is my code,


<script src="" type="text/javascript" charset="utf-8"></script>

<script type="text/javascript" language="javascript">


var apiKey =21308741;

var sessionId = "2_MX4yMTMwODc0MX4xMC4xMC4xMC4zN35GcmkgTm92IDAyIDIzOjUxOjU4IFBEVCAyMDEyfjAuMDc0NzQ5Mjl-";
var VIDEO_WIDTH = 310;
var VIDEO_HEIGHT = 200;
var VIDEO_WIDTH1 = 310;
var VIDEO_HEIGHT1 = 400;
var publisher;
var session;
var subscribers = {};
var txt="";

function StartConference() {

alert("Conf Started");

TB.addEventListener("exception", exceptionHandler);

if (TB.checkSystemRequirements() != TB.HAS_REQUIREMENTS) {
alert("Please upgrade to the latest version of Flash.");
} else {



//To start the connecation
function connect() {

alert("connect called");
session = TB.initSession(sessionId); // Initialize session
alert("session intiialized");
// Add event listeners to the session
session.addEventListener('sessionConnected', sessionConnectedHandler);
session.addEventListener('streamCreated', streamCreatedHandler);
session.addEventListener('connectionCreated', connectionCreatedHandler);
session.addEventListener('sessionDisconnected', sessionDisconnectedHandler);
session.addEventListener('connectionDestroyed', connectionDestroyedHandler);
session.addEventListener('streamDestroyed', streamDestroyedHandler);

session.connect(apiKey, tokenGen);
alert("session connected");


//To disconnection the session
function leaveConference() {



//To start publishing our video
function startPublishing() {
if (!publisher) {
alert("publishing my video started");
var parentDiv = document.getElementById('myCamera');
// Create a div for the publisher to replace
var publisherDiv = document.createElement('div');
publisherDiv.setAttribute('id', 'opentok_publisher');
var publisherProps = { width: VIDEO_WIDTH, height: VIDEO_HEIGHT };
// Pass the replacement div id and properties
publisher = TB.initPublisher(apiKey,, publisherProps);
alert("publishing my video finished");



//This is Our Video
function sessionConnectedHandler(event) {
alert(event.streams.length+"My Stream");

for (var i = 0; i < event.streams.length; i++) {


//New Arrived Streams
function streamCreatedHandler(event) {
alert(event.streams.length+"Other Streams");

for (var i = 0; i < event.streams.length; i++) {

// Subscribe to any new streams that are created


function streamDestroyedHandler(event) {
// This signals that a stream was destroyed. Any Subscribers will automatically be removed.
// This default behaviour can be prevented using event.preventDefault()

function sessionDisconnectedHandler(event) {

// will automatically be removed. This default behaviour can be prevented using event.preventDefault()
publisher = null; = "Meeting.aspx";

function connectionDestroyedHandler(event) {
// This signals that connections were destroyed

function connectionCreatedHandler(event) {
// This signals new connections have been created.

//Streams of that session
function subscribeToStreams(stream) {

if (stream.connection.connectionId == session.connection.connectionId) {

var subscriberDiv = document.createElement('div'); // Create a div for the subscriber to replace
subscriberDiv.setAttribute('id', stream.streamId); // Give the replacement div the id of the stream as its id.
var subscriberProps = {height: VIDEO_HEIGHT1, width: VIDEO_WIDTH1 };
//subscribers[stream.streamId] =
session.subscribe(stream,, subscriberProps);


//Exception Handler

function exceptionHandler(event) {
// Retry session connect
if (event.code === 1006 || event.code === 1008 || event.code === 1014) {
alert('There was an error connecting. Trying again.');
session.connect(apiKey, tokenGen);

//To Show and Hide the controls..

function show(id) {
document.getElementById(id).style.display = 'block';

function hide(id) {
document.getElementById(id).style.display = 'none';



<body onload="StartConference();">

<div class="span-17half last">
<div class="span-8 last" id="myCamera" style="float: left;border:1px solid #999999;"></div>
<div class="span-8 last" id="subscribers" style="float: left;border:1px solid #999999;margin-left:10px;"></div>



Was this post helpful? (0)
Posts: 2
Joined: Mon Oct 08, 2012 7:30 am
Thumbs Up: 1

Re: PlainHtml Content

Postby jtsai » Mon Nov 05, 2012 1:56 pm


Is this page all green for you?

Was this post helpful? (0)
User avatar
Posts: 4822
Joined: Wed Sep 14, 2011 3:00 pm
Thumbs Up: 199

Re: PlainHtml Content

Postby simran » Thu Nov 15, 2012 2:26 pm

I am experiencing this same issue. I clicked on the link above to troubleshoot and it tells me that it could not connect to port 443. So I looked up how to open up the port on windows 7 (my OS) and I found a few ways to test if 443 was in fact open. According to the test Microsoft provides on their support site, port 443 is open in my OS. Am I missing something? Could the troubleshooter be wrong? Have you seen an error like this before? Any suggestions? I've hit a roadblock here and I am really excited to try this out...
Was this post helpful? (0)
Posts: 2
Joined: Thu Nov 15, 2012 1:49 pm
Thumbs Up: 0

Re: PlainHtml Content

Postby mumm » Thu Nov 15, 2012 4:17 pm

Hey Simran,

Could you try running the demo from a webserver (either a remote or local one) instead of running it straight from the filesystem? I suspect your port 443 is open, and the diagnostic tool is showing it correctly, but Flash when it is running from the filesystem is not able to.

Was this post helpful? (0)
Posts: 317
Joined: Wed May 18, 2011 12:10 am
Thumbs Up: 27

Re: PlainHtml Content

Postby simran » Mon Nov 19, 2012 9:49 am

That was my problem.
Was this post helpful? (0)
Posts: 2
Joined: Thu Nov 15, 2012 1:49 pm
Thumbs Up: 0

Return to JavaScript

Who is online

Users browsing this forum: No registered users and 0 guests