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

JavaSacript demo #73

Closed KAXER closed 9 years ago

KAXER commented 10 years ago

Hi, Chirs, I'm trying to use the trick about the "socket open", using the Websocket API. But I have this messages: image

Could you said me what I'm doing wrong?

Thanks in advance :)

iamruinous commented 10 years ago

Hi KAXER,

The jsconsole is using the javascript wrapper library (http://skynet.im/#javascript_api). You can call status() with a callback, you don't need to emit it.

conn.status(function(data){
    console.log(data)
});

Your example would work if you were creating a direct socket.io connection. LMK if you run into any other troubles.

KAXER commented 10 years ago

HI iamruinous, Thanks for your help. very useful tip. I'm trying also use the websockets API from MS-DOS, but I have this the answer : {"errot": "unauthorized"} when I use command curl -X GET: http://skynet.im/suscribe/UUID?token=xxxx

Could you said me what I'm doing wrong? Thanks a lot in advance image

chrismatthieu commented 10 years ago

Our REST API now requires UUID and token authorization passed in the headers rather than the querystring. Here is a curl example from our docs:

curl -X GET http://skynet.im/subscribe/ad698900-2546-11e3-87fb-c560cb0ca47b?token=123 --header "skynet_auth_uuid: {my uuid}" --header "skynet_auth_token: {my token}"

KAXER commented 10 years ago

Hi Chirs, Please, give me the correct direction or advice , because I try but the same error happened-->{"error": "unauthorized"}

  1. curl -X POST -d "type=drone&color=black" http://skynet.im/devices
  2. After the step 1 the ms-dos console displays: "uuid":"390ee421-2f94-11e4-97c4-d1f36657f568" and this my "token":"ioike40hvm4sfw29xw0pmvqodvtmlsor"
  3. To subscribe to this uuid (deployed in the demo): 37759f21-2f97-11e4-97c4-d1f36657f568 token:0vhikfgct52v2huxrzy9jd7k4qkyy14i

4.is it correct this line??: curl -X GET http://skynet.im/subscribe/37759f21-2f97-11e4-97c4-d1f36657f568?token=0vhikfgct52v2huxrzy9jd7k4qkyy14i/390ee421-2f94-11e4-97c4-d1f36657f568/ioike40hvm4sfw29xw0pmvqodvtmlsor

5.- {"error":"unauthorized"}

Also I tried with this line but I had the same result: curl -X GET http://skynet.im/subscribe/ad698900-2546-11e3-87fb-c560cb0ca47b?token=123/skynet_auth_uuid: {390ee421-2f94-11e4-97c4-d1f36657f568}/skynet_auth_token: {ioike40hvm4sfw29xw0pmvqodvtmlsor}

and this : curl -X GET http://skynet.im/subscribe/ad698900-2546-11e3-87fb-c560cb0ca47b?token=123 --header "skynet_auth_uuid: {390ee421-2f94-11e4-97c4-d1f36657f568}" --header "skynet_auth_token: {ioike40hvm4sfw29xw0pmvqodvtmlsor}" {"error":"unauthorized"}

Thanks a lot in advance

chrismatthieu commented 10 years ago

Try this:

curl -X GET http://skynet.im/subscribe/37759f21-2f97-11e4-97c4-d1f36657f568 --header "skynet_auth_uuid: 37759f21-2f97-11e4-97c4-d1f36657f568" --header "skynet_auth_token: 0vhikfgct52v2huxrzy9jd7k4qkyy14i"

chrismatthieu commented 10 years ago

The above curl example subscribes to only the device's broadcast messages where devices="*". This example subscribes to all messages (in and out):

curl -X GET "http://skynet.im/subscribe/37759f21-2f97-11e4-97c4-d1f36657f568?token=0vhikfgct52v2huxrzy9jd7k4qkyy14i" --header "skynet_auth_uuid: 37759f21-2f97-11e4-97c4-d1f36657f568" --header "skynet_auth_token: 0vhikfgct52v2huxrzy9jd7k4qkyy14i"

KAXER commented 10 years ago

I tried , but appear culrl:(52) empty reply from server image

chrismatthieu commented 10 years ago

Ah, the server is timing out the request. This API should behave like a streaming API waiting and listening for data. We'll take a closer look at this - thanks!

KAXER commented 10 years ago

Awsome :+1: Thank to you...

chrismatthieu commented 10 years ago

Just added Connection: keep-alive to the HTTP headers on the subscribe and data streaming endpoints. The update is committed on GitHub and deploying to our AWS servers now...