Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connect socket to sails from test

I'm trying to test sails socket connections from mocha.

    var socketIOClient = require('socket.io-client');
    var sailsIOClient = require('sails.io.js');

    // Instantiate the socket client (`io`)
    // (for now, you must explicitly pass in the socket.io client when using this library from Node.js)
    var io = sailsIOClient(socketIOClient);

    // Set some options:
    // (you have to specify the host and port of the Sails backend when using this library from Node.js)
    io.sails.url = 'http://localhost:1337';

It gives an error

Uncaught Error: The provided socket.io client (io) has already been augmented into a Sails socket SDK instance (it has io.sails).

Am I doing something wrong? sails version 0.12.3, socket.io-client 1.4.6

like image 391
Վիգեն Սարգսյան Avatar asked Dec 06 '25 05:12

Վիգեն Սարգսյան


1 Answers

Your problem is posible because you have install multiples sails.io.js

You should view this line of code the sails.io.js

review your code

like image 57
William Penagos Avatar answered Dec 07 '25 18:12

William Penagos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!