octoblu / meshblu

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

Different ipAddress when register a device by HTTP or by Socket.io, and (meshblu.identity or meshblu.identify)? #120

Closed eternaltao closed 8 years ago

eternaltao commented 8 years ago

I use the HTTP API to register a Device, the ipAddress is 115.236.14.185 curl -X POST -d "type=ga_connector" https://meshblu.octoblu.com/devices

{"uuid":"8c4f61e0-70b0-4057-aa74-71e32250f719","online":false,"type":"ga_connector","ipAddress":"115.236.14.185","token":"12ff0ab0bd1521b5f2fca47cf2fb398d662c7608","geo":{"range":[1944849928,1944850251],"country":"***","region":"02","city":"***","ll":[****],"metro":0},"meshblu":{"hash":"b3MjY67M6agM3WT6Ht8IPwp098A3sCIw8VuZAy8Ez7I="}}

When I used the socket.io, the ipAddress is 172.17.0.1

{ uuid: '19ea7d98-95ad-4542-b7cc-b5414c0818ec',
  online: true,
  discoverWhitelist: [],
  configureWhitelist: [],
  receiveWhitelist: [],
  sendWhitelist: [],
  ipAddress: '172.17.0.1',
  token: '$2a$08$MVXUsNDrrlwsdDMCjBZN8ud.ZJO5DKzJi0dU4QIk9KDFh1kRCQ1Da',
  geo: null,
  meshblu: { hash: 'cEtzL//aJTp1thL416fJTnVFHCcYyfzcL+XUUAK0tY8=' },
  protocol: 'websocket',
  socketid: '_T6JJH9T6980EKYsAATY',
  secure: false,
  onlineSince: '2015-12-28T11:43:44.261Z' }

My client code in socket.io (I didn't require('meshblu'), because I must implement it by C++)

var debug = require("debug")('socket.io-client');
var socketIoClient = require('socket.io-client');

var socket = socketIoClient("wss://meshblu.octoblu.com");

socket.on("connect", function(){
        socket.emit('identity', {
                uuid: '19ea7d98-95ad-4542-b7cc-b5414c0818ec',
                token: 'e68e04f2e7a1c0040c6d31af569bedba5542779d'
        }, function(){});

        socket.on('ready', function(){

                socket.emit("whoami", {}, function(who){
                        console.log(who);
                });
        });
});

And I tried the sample of socket.io to register: ipAddress: '172.17.0.1'

{ uuid: 'c8253a01-ef2d-4f9f-a5a1-4ed811a30368',
  online: false,
  type: 'ga_connector',
  socketid: 'rHEfvoJibbndYZgNAAJn',
  ipAddress: '172.17.0.1',
  token: '812d291b706e0a6609c33d2dbc73af7e383a90fc',
  geo: null,
  meshblu: { hash: 'nmK/R02EeFfuf0c3ZvQ/BQYjWB5qmOARcUVyKH3iFkg=' } }

The nodejs code: (meshblu.identify is right but not meshblu.identity)

var Meshblu=require('meshblu');
var meshblu=Meshblu.createConnection({
});

meshblu.identify({
        uuid: "44d05f47-9ef8-4c74-b47a-f5d383ac3ff1",
        token: "55748d20015cd749c719a5edf1a00560b3d058a8",

}, function(result) {});

meshblu.register({"type": "ga_connector"}, function(result) {
        console.log(result);
});