octoblu / meshblu

Meshblu is a cross-protocol IoT machine-to-machine messaging system.
https://meshblu.readme.io/
MIT License
816 stars 181 forks source link

About message and send / receive whitelist #119

Closed eternaltao closed 8 years ago

eternaltao commented 8 years ago

Merry Christmas!

I'm sorry to disturb you on Christmas day.

I get stuck in the problem of message sending and receiving.

Client A is in Client B's whitelist(discover,config,send reveive), and A claimDevice and subscribe B.

Then A emit a message to B, but B can't receive the message.

I can't find out why B can't receive the message.

please give me some advice.

Thanks a lot.

Client A:

var socketIoClient = require('socket.io-client');
var socket = socketIoClient("wss://localhost");
//var socket = socketIoClient("wss://meshblu.octoblu.com");

console.log("##1");

socket.on("connect", function(){

        socket.emit('identity', {
                uuid: 'e8841017-5d78-4ded-8b1b-e0d566fb10d6',
                token: 'd0e198d11bf0b07dcdfaca1cf6edb54ea5abc111'
        }, function(){});

        socket.on('ready', function(readyMsg){
                console.log("ready go...");               
                /*      
                socket.emit("update",{uuid:"2e0f9e00-f926-4818-b14a-88cb4a74fe50", sendWhitelist:["e8841017-5d78-4ded-8b1b-e0d566fb10d6"],receiveWhitelist:["e8841017-5d78-4ded-8b1b-e0d566fb10d6"]}, function(update){
                        console.log("update...");
                        console.log(update);
                });
                */
                socket.emit('message', {"devices":"*", "message":{"lock":"on"}});
        });

        socket.on('notReady', function(notready){
                console.log("not ready");
                console.log(notready);
        });
});

Client B:

var socketIoClient = require('socket.io-client');
var socket = socketIoClient("wss://localhost");
console.log("##1");
socket.on("connect", function(){
        socket.emit('identity', {
                uuid: '2e0f9e00-f926-4818-b14a-88cb4a74fe50',
                token: '26b2e6810d4a0b17bb5364dbb5347c699924bd2f'
        }, function(){});

        socket.on('ready', function(){
                console.log("start to receive msg!...");
                socket.on("message", function(msg){
                        console.log("received msg...");
                        console.log(msg);
                });
        });
});
console.log("##2");

socket.on("connect_error", function(e){
        console.log("connect_error");
        console.log(e);
});

Meshblu server:

^[[A^Cdev@ubuntu:~/workspace/meshblu$ sudo TOKEN=02012bf7c9622e470e468e9fcfde8a6ba74c5ca2 SSL_PORT=443 SSL_CERT=~/workspace/certs/server.crt SSL_KEY=~/workspace/certs/server.key npm start

> meshblu-server@1.14.16 start /home/dev/workspace/meshblu
> node ${NODE_FLAGS} server.js --http --mqtt --coap

Meshblu (formerly skynet.im) development environment loaded... 

Starting CoAP... done.
Starting HTTP/HTTPS... done.
Starting MQTT... done.
CoAP listening at coap://localhost:5683
HTTP listening at 0.0.0.0:80
HTTPS listening at 0.0.0.0:443
MQTT listening at mqtt://0.0.0.0:1883