intel / iotivity-node

Node.js bindings for IoTivity
https://www.iotivity.org/
42 stars 44 forks source link

No observers in list when running server.observable.js #167

Open xiaoyu3x opened 6 years ago

xiaoyu3x commented 6 years ago

I got the following information when running server.observable.js and client.observe.js. Client outputs: selection_029

But sever always continuously outputs "Sensor data has changed,No observers in list " selection_028

I added console.log into iotivity.OCCreateResource(), but I found no information output.

gabrielschulhof commented 6 years ago

46 is the code for a denied request.

As of the latest iotivity-node, security is enabled. Therefore, for successful communication between the client and the server, you need to create oic_svr_db.dat files for both the client and the server. The process and links to sample files can be found at https://wiki.iotivity.org/security_resource_manager

You create the files by processing a JSON file using json2cbor, a tool provided by iotivity. You can build the tool as part of iotivity with

scons SECURED=1 resource/csdk/security/tool

You need to place the resulting .dat files into a subdirectory of ~/.iotivity-node

The name of the subdirectory is the sha256sum of the absolute path of the JS file. So, for a file named "/home/user/project/server.ocf.js", you can obtain the sha256sum as follows:

echo -n '/home/user/project/server.ocf.js' | sha256sum

This yields

ff85509781006eb0da9c4e278e1a685d9b55e09bb03f4115d07fbe6a92d4569e -

Thus, you would

mkdir -p ~/.iotivity-node/ff85509781006eb0da9c4e278e1a685d9b55e09bb03f4115d07fbe6a92d4569e

and

cp oic_svr_db.dat ~/.iotivity-node/ff85509781006eb0da9c4e278e1a685d9b55e09bb03f4115d07fbe6a92d4569e

After repeating this process for both the client and the server, and having made sure that the files have the correct contents, you can launch the server.

https://github.com/otcshare/iotivity-node/blob/master/SECURITY.md also contains these instructions.

There is a second approach to creating the .dat files. If you take this approach, you provide the server with a sample .dat file, after which you provision it using the iotivity provisioning client example tool. This approach is described here: https://github.com/otcshare/iotivity-node/blob/master/js/README.md

On Fri, Jan 5, 2018 at 3:01 AM, xiaoyu3x notifications@github.com wrote:

I get the following information when running server.observable.js and client.observe.js. Client output: [image: selection_029] https://user-images.githubusercontent.com/17694094/34600089-b6aa063c-f230-11e7-9155-071d8145206e.png

But sever always continuously outputs "Sensor data has changed,No observers in list " [image: selection_028] https://user-images.githubusercontent.com/17694094/34600206-4e93a426-f231-11e7-8bd7-5137d8b80c7f.png

I added console.log into iotivity.OCCreateResource(), but I find no information output.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/otcshare/iotivity-node/issues/167, or mute the thread https://github.com/notifications/unsubscribe-auth/AA7k0TFfImyMjvP18J8tXw3dgitj_pvUks5tHdbqgaJpZM4RUJAe .

xiaoyu3x commented 6 years ago

hi, @gabrielschulhof Why not found 'provisioningclient'(step 5 in README.md) for me after run scons SECURED=1 resource/csdk/security/tool, and I can't get 'oic_svr_db_client.dat'.

Please help to me.

gabrielschulhof commented 6 years ago

It's in out///release/resource/csdk/security/tool ...

means your platform, like "linux", or "win32", and means your processor architecture, like "x86_64". On Sun, Jan 7, 2018 at 9:36 PM, xiaoyu3x wrote: > hi, @gabrielschulhof > Why not found 'provisioningclient'(step 5 in README.md > ) for me after > run scons SECURED=1 resource/csdk/security/tool, and I can't get > 'oic_svr_db_client.dat'. > > Please help to me. > > — > You are receiving this because you were mentioned. > Reply to this email directly, view it on GitHub > , > or mute the thread > > . >
xiaoyu3x commented 6 years ago

hi, @gabrielschulhof I still can't find oic_svr_db_client.dat and the following is my folder: selection_033

What pre-condition I need?

xiaoyu3x commented 6 years ago

This issue is reproduced with commit 35461e8

yannS2016 commented 5 years ago

was this ever resolved?

gabrielschulhof commented 5 years ago

@yannS2016 I'm having trouble reproducing this issue. If your access control works properly, you will not get status 46. Are you seeing this too?