I have some troubles while connecting a Socket.io instance from Sailsjs and Kurento (locally, on a Docker instance).
When I try to connect to Kurento with this code (on a Sailsjs service):
var kurento = require('kurento-client');
var ws_uri = 'ws://localhost:8812/kurento';
kurento(ws_uri, function(error, _kurentoClient) {
// Logic here
});
I got this error on the console (the callback is never called):
[SyntaxError: Unexpected token u001b[90m{"id":0,"jsonrpc":"2.0","result"{"value":"pong"}}\n\u001b[39m'
[SyntaxError: Unexpected token u001b[90m{"id":1,"jsonrpc":"2.0","result":{"hierarchy":["kurento.MediaObject"],"qualifiedType":"kurento.ServerManager","sessionId":"0296ed75-bba7-4728-a4d8-25bb5715f442","type":"ServerManager"}}\n\u001b[39m'
I understand that there is a problem while parsing the response from the Kurento server (probably an encoding problem), but I can't figure out where this response is parsed (body-parser of Sails?).
When I run the tutorial examples, it runs normally, but not with Sails.
Anyone have faced the same issue?
That error is caused by JSON color code. You can fix "unpack" function in JSONrpc.js (library) by removing color code - delete color code from string. That's all.