• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Cannot set property 'readyState' of undefined cfwebsocketCore.js:54

New Here ,
Jul 27, 2013 Jul 27, 2013

Copy link to clipboard

Copied

I am trying to test the cfwebockets but i keep getting this error when i go to the webpage where i have the sample code. i have downloaded sample code from the adobe developers and it still gives me this error.

I am using cF10 standard with websockets enabled on a win 2008 server 64bit. I am not getting any reaction from websockets as well. It won't subscribe or open connection. Any help?

Here is the code i am using:

<script>

       //messagehandler recieves all the messages from websocket

       function mycbHandler( messageobj)

       {

              var message = ColdFusion.JSON.encode(messageobj);

           var txt=document.getElementById("myDiv");

           txt.innerHTML +=message  +"<br>";

       }

      

       //openhandler is invoked when socket connection is

       function openHandler()

       {

              var txt=document.getElementById("myDiv");

           txt.innerHTML +="open Handler invoked <br>";

       }

      

       function subscribeMe()

       {

              var channelname = document.getElementById("channelname").value;

              mywsobj.subscribe(channelname);

       }

       function getSubscribers()

       {

              var channelname = document.getElementById("channelname").value;

              mywsobj.getSubscriberCount(channelname);

       }

       function unsubscribe_Me()

       {

           var channelname = document.getElementById("channelname").value;

           mywsobj.unsubscribe(channelname);

       }

       function publishClient()

       {

              var channelname = document.getElementById("channelname").value;

              var message =  document.getElementById("msg").value;

       mywsobj.publish(channelname,message);

       }

       function get_Subscriptions()

       {

           mywsobj.getSubscriptions();

       }

       function invokenpublish()

       {

              cfcname = document.getElementById("cfcname").value;

              fnname = document.getElementById("fnname").value;

              channelname = document.getElementById("channelname").value;

              mywsobj.invokeAndPublish(channelname, cfcname, fnname);      

       }

       function invokefn()

       {

              cfcname = document.getElementById("cfcname").value;

              fnname = document.getElementById("fnname").value;

              channelname = document.getElementById("channelname").value;

              mywsobj.invoke(cfcname, fnname); 

       }

       function opensocket()

       {

              var txt=document.getElementById("myDiv");

              txt.innerHTML+="opening socket"+"<br >";

              x=mywsobj.openConnection();

       }

       function stopsocket()

       {

              var txt=document.getElementById("myDiv");

              txt.innerHTML+="closing socket"+"<br >";

              x=mywsobj.closeConnection();

       }

       function checksocket()

       {

              var x=mywsobj.isConnectionOpen();

              var txt=document.getElementById("myDiv");

              txt.innerHTML+=x+"<br >";

       }

</script>

<body>

<form name="f">

<!---Define JS websocket object name and messagehandler and openhandler  --->

<cfwebsocket name="mywsobj" onMessage="mycbHandler" onOpen="openHandler"/>

<br> Subscribe to:

<input  id="channelname" name="channelname" type="text" value="stocks" >

<input  id="stocksSubscribe" type="button" value="stocksSubscribe" onclick="subscribeMe();">

<input  id="unsubscribeMe" type="button" value="unsubscribeMe" onclick="unsubscribe_Me();">

<input  id="getSubscribersCF" type="button" value="getSubscribersCF" onclick="getSubscribers();">

<input  id="getSubscriptions" type="button" value="getSubscriptions" onclick="get_Subscriptions();">

<br>

Message :<input id="msg" type="text" >

<input  id="publishMe" type="button" value="publishMe" onclick="publishClient();">

<br>

CFC Name: <input  id="cfcname" name="cfcname" type="text" value="invokeandpublish" >

Function Name: <input  id="fnname" name="fnname" type="text" value="publishall" >

<input  id="invoke_publish" type="button" value="invoke_publish" onclick="invokenpublish();">

<input  id="invoke" type="button" value="invoke" onclick="invokefn();">

<br>

<input  id="stop" name ="Close" type="button" value ="stop" onclick="stopsocket()" >

<input  id="open" name ="Open" type="button" value ="open" onclick="opensocket()" >

<input  id="check" name ="Check" type="button" value="check" onclick="checksocket()" >

<br>

<div id="myDiv"></div>

</form>

</body>

</html>

Views

2.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 21, 2013 Sep 21, 2013

Copy link to clipboard

Copied

LATEST

I had the same issue. The problem turned out to be the default port used by websockets (8575) wasn't open by default. Once this was opened, the readystate error disappeared.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation