Response Websocket Backend

Hi, I'm doing a web socket in a comment view, on server side, what i need to send to the client to load the comments?. I was sending just the json with the data but i get an error


  • edited June 30

    Hello @Dalaz,

    I would like to point you to the direction of our guide covering integration with Websockets in detail, which should help you out with your endeavour:
    The demo can be found via this link (or at the very top/bottom of the article).

    The backend is as simple as possible:

    const WebSocket = require('ws');
    //live updates for data sample
    const wss = new WebSocket.Server({ port:8080 });
    wss.on('connection', function connection(ws) {
        ws.on('message', function incoming(message) {
            // save message to DB
            message = _dummySave(message);
            // send it to all clients
            wss.clients.forEach(function each(client) {
    //emulate saving to db, where record id usually defined
    function _dummySave(message){
        message = JSON.parse(message);
        if (message.operation == "insert"){
   = "s"+;
        message = JSON.stringify(message);
        return message;

    For starters, try to implement the logic as described in our guide.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion