Best way to create a persistent socket connection between raspberry pi and server both running nodejs

I am setting up a web connected sprinkler using the raspberry pi which is running pi.js atop of nodejs. I'm also running nodejs for my server. I need these two to have a persistent socket connection between them: the raspberry pi and the server. I'm thinking of socket.io

Does anyone have experiences doing something like this with socket.io? Or would using the coAP protocol make more sense? Or something else entirely?

After marching down the socket.io path for a while I realized it wasn't the best fit--especially considering it was more designed and built with the browser in mind. So, I stepped back to what socket.io uses as a dependency: https://github.com/einaros/ws. This npm package is much less concerned with the browser and more suited to my needs in the whole internet of things approach.

My code looks like this:

SERVER:

var WebSocketServer = require('ws').Server
, http = require('http')
, FS = require('fs')
, bodyParser = require('body-parser')
, express = require('express')
, app = express();


app.use(bodyParser.json());
app.use(express.static(__dirname + '/app'));

var server = http.createServer(app);
server.listen(8080);

var wss = new WebSocketServer({server: server});

wss.on('connection', function(ws) {
    ws.on('message', function(data, flags) {
        console.log(data);
    });

    ws.on('close', function() {
        console.log('stopping client interval');
    });

    console.log('started client interval'); 
}); 

CLIENT (Being the Raspberry Pi for controlling water valves)

var WebSocket           = require('ws');

var ws = new WebSocket("ws://0.0.0.0:8080");
ws.on('open', function() {
    console.log('should be now connected');
}); 

ws.on('message', function(data, flags) {
    console.log(JSON.parse(data));
}