Highlighted

Coldfusion Websockets server with Angular front-end?

New Here ,
Jan 31, 2015

Copy link to clipboard

Copied

Anyone here have any success with a CF server running WebSockets and an AngularJS front-end?  I'm having some trouble and hoping for help.

Just one channel on the server:

     THIS.wschannels = [{name="test1"}];

As a note, this Application.cfc is in a subdirectory (api/rest) where we're running our taffy rest backend.  Should it be moved to the top lever, or does it matter?

On the front end I've tried a few things along these lines:

    var ws = new WebSocket("ws://localhost:8575/api/rest");

    ws.onopen = function(){ 

        console.log("Socket has been opened!"); 

    };

   

    ws.onmessage = function(message) {

        listener(JSON.parse(message.data));

    };

    function listener(data) {

      var messageObj = data;

      console.log("Received data from websocket: ", messageObj);

    }


$scope.send = function() {

      ws.send("Hello WebSockets!");

};


I'm running to local angular clients on different ports and runnign the send from one.  Never see a response anywhere.  Suggestions?


Any leads appreciated.

Jonathan

Views

470

Likes

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

Coldfusion Websockets server with Angular front-end?

New Here ,
Jan 31, 2015

Copy link to clipboard

Copied

Anyone here have any success with a CF server running WebSockets and an AngularJS front-end?  I'm having some trouble and hoping for help.

Just one channel on the server:

     THIS.wschannels = [{name="test1"}];

As a note, this Application.cfc is in a subdirectory (api/rest) where we're running our taffy rest backend.  Should it be moved to the top lever, or does it matter?

On the front end I've tried a few things along these lines:

    var ws = new WebSocket("ws://localhost:8575/api/rest");

    ws.onopen = function(){ 

        console.log("Socket has been opened!"); 

    };

   

    ws.onmessage = function(message) {

        listener(JSON.parse(message.data));

    };

    function listener(data) {

      var messageObj = data;

      console.log("Received data from websocket: ", messageObj);

    }


$scope.send = function() {

      ws.send("Hello WebSockets!");

};


I'm running to local angular clients on different ports and runnign the send from one.  Never see a response anywhere.  Suggestions?


Any leads appreciated.

Jonathan

Views

471

Likes

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
Jan 31, 2015 0
New Here ,
Nov 22, 2017

Copy link to clipboard

Copied

I had this same issue and found an answer on stack overflow.
javascript - connect to coldfusion websocket from HTML page - Stack Overflow

Likes

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
Reply
Loading...
Nov 22, 2017 0