Error connecting web socket in Coldfusion

318 Views Asked by At

Today I was trying to start with the 'Hello World' program in Web-socket with ColdFusion 10. I have started with the sample example given in the adobe forum.

Application.cfc

<cfcomponent output="false">

<cfscript>
     this.name = "helloworld";
     this.wschannels = [{name="world"}]; 
</cfscript> 

</cfcomponent>

index.cfm

<cfwebsocket name="myworld" onMessage="msgHandler" subscribeto="world" onOpen="openHandler"/> 
<script> 
var msgHandler = function(message) {
     // Get data from the recieved message token
     console.log(message);
      var data = message.data;
      if(data) {
         // If data is present write it to the div 
         var txt=document.getElementById("myDiv"); 
         txt.innerHTML+= data + "<br>"; 
         } 
    }
var sayHello = function() {
     // Client says Hello World 
     myworld.publish("world","Hello World! WebSocket is here !!"); }
     var openHandler = function() { 
        // do nothing 
     } 
</script> 
<input id="hello" type="button" value="Say Hello!" onclick="sayHello();"> 
<div id="myDiv"></div>

But it is not working. Error ScreenShot: enter image description here

Please help.

0

There are 0 best solutions below