Skip to main content
Participant
March 12, 2015
Question

Channel Doesn't Exist or is not running

  • March 12, 2015
  • 1 reply
  • 1573 views

I am using CF 11, IIS 7.5 and windows 7 pro. when I create a sample application using websockets I get the following results:

{"msg":"ok","code":0,"clientid":40495741,"ns":"coldfusion.websocket.channels","reqType":"welcome","type":"response"}

{"msg":"Channel 'stocks' doesn't exist or is not running.","code":-1,"clientid":40495741,"ns":"coldfusion.websocket.channels","reqType":"subscribe","type":"response"}

can someone help me understand why I am getting the second error message.

Thanks

    This topic has been closed for replies.

    1 reply

    Inspiring
    March 12, 2015

    The channel is what the socket connection is trying to connect to. You usually define them in the Application.cfc. It looks something like this:

    this.wschannels = [{name="stock", cfclistener="stock"}];

    You are getting the error because the channel "stocks" is not listed here. Based on your previous forum post I imagine you have adapted a sample from somewhere but have not changed all the bits completely.

    Chaz__WAuthor
    Participant
    March 13, 2015

    thx haxtbh,

    I have this in my application.cfc

       this.wschannels=[{name="stocks"}];

    and this is in my index.cfm

    <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;

     

       }

       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()

       {

     

       }

       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>

    <form name="f">

     

    <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>

    yes this is something I copied for a sample that I am trying to get it to work so I can understand how this works.

    thanks for your help.

    if I am missing something please let me know.

    thanks,

    Inspiring
    March 13, 2015

    When you run the page which button are you clicking first?

    Where did you get this sample from?