JavaScript How to connect Socket.IO-Client to Sails.js server? connect socket client,connect socket client to server,connect socket

I've spent quite a while trying to connect Socket.IO-Client to a server running on Sails.js framework. The client is basically a simple JavaScript application running with Node.js on Raspberry Pi.

The idea is that a simple device connects to a server, the server then registers the device and subscribes it for messages. The device receives a message from the server and performs some actions. I don't want the client to be dependant on any framework and, for that reason, I am trying to avoid using Sailsjs-socket.io-client. At the moment both server and the client are running on my local machine. Here is the code:

// Server side. Sails.js. DevicesController.js

module.exports = {

  handshake: function (req, res) {
    if (!req.isSocket) return res.badRequest();
    Devices.create({}).exec(function (error, data) {
      Devices.subscribe(req.socket, data);
    });
    return res.ok();
  }

};


// Client side
var socket = require('socket.io-client')('http://localhost:1337/devices/handshake');

socket.on('error', function(e) {
    console.log(e);
    // Here I get 'Invalid namespace'
});
Answer:1

I'm using Gulp to run Webpack because some things that are trivial with Gulp are messy with Webpack, such as multiple outputs. However, babel-loader doesn't seem to be doing anything. When I have JSX ...

I'm using Gulp to run Webpack because some things that are trivial with Gulp are messy with Webpack, such as multiple outputs. However, babel-loader doesn't seem to be doing anything. When I have JSX ...

  1. gulp using webpack
  2. using gulp and webpack together

Here is the code: $q.all($q.when(3), $q.when(5)).then(function (values) { console.log(values); }); The output is the following: {"$$state":{"status":1,"value":3}} The manual states that: ...

Here is the code: $q.all($q.when(3), $q.when(5)).then(function (values) { console.log(values); }); The output is the following: {"$$state":{"status":1,"value":3}} The manual states that: ...

I'm having problems serving mp3 files in NodeJS. var filestream = fs.createReadStream('file.mp3'); filestream.on('open', function() { var stats = fs.statSync('file.mp3'); var fileSizeInBytes = ...

I'm having problems serving mp3 files in NodeJS. var filestream = fs.createReadStream('file.mp3'); filestream.on('open', function() { var stats = fs.statSync('file.mp3'); var fileSizeInBytes = ...

  1. serving static files nodejs
  2. nodejs serving files
  3. serve static files nodejs

I have a HTML form and I am converting that form inputs to a object using the below code: var inputs = $("form :input"); var obj = $.map(inputs, function (x, y) { return { Key: x.name, ...

I have a HTML form and I am converting that form inputs to a object using the below code: var inputs = $("form :input"); var obj = $.map(inputs, function (x, y) { return { Key: x.name, ...

  1. remove key value from object javascript
  2. remove key value from dictionary python
  3. remove key value pair from dictionary python
  4. remove key value from dict python
  5. remove key value from hash ruby
  6. remove key value pair from hash ruby
  7. remove key value from dictionary
  8. remove key value pair from dictionary javascript
  9. remove key value from array php
  10. remove key value pair from dictionary c#
  11. remove key value pair from map c++
  12. remove key value from dict
  13. remove key value from map java
  14. remove key value from dictionary javascript
  15. remove key value pair from map java
  16. remove key value from json object javascript
  17. remove key value from json python
  18. remove key value from map golang
  19. remove key value pair from array javascript
  20. remove key value from json