I'm trying to call a socketio function from python, but I'm getting the following error message :
NoSocket: There are no clients on the channel: global
As I've just started using socketio, I'm not familiar with it, so I would like to know why am I getting this error.
Here is the python :
print "starting test"
while s <= total:
print total
percent = (100 * s) / total
print percent
res["data"]["value"] = percent
socket.broadcast_channel(json.dumps(res), channel="global")
time.sleep(1)
s = s + 1
print "test is over"
and here is the socketio part :
var socket = new io.Socket();
socket.connect();
socket.subscribe('global');
console.log('subscribed');
socket.on('message', function (message) {
var data = JSON.parse(message);
if (data.type == "init") {
console.log("Receiving Init info");
}
else if (data.type == "record") {
console.log("Receiving record info");
if (data.data.object == "progress-bar") {
var elem = document.getElementById("myBar");
elem.style.width = data.data.value + '%';
document.getElementById("label").innerHTML = data.data.value * 1 + '%';
}
}
else {
console.log("Receiving unknown data type : " + JSON.stringify(data));
}
});
Any idea why? Thanks in advance.