intel / iotivity-node

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

Sometimes OCF Client can't find OCF Server resource #135

Closed wanghongjuan closed 7 years ago

wanghongjuan commented 7 years ago

Description

When using client.js to discovery the server resources , sometimes it can't find the resource, but using iot-rest-api-server/test/oic-get to get the resource, it can find the resources every time. I am not clear the reason, is there anything missing?

Reproduce Steps:

  1. Prepare two Joule boards with iot-ref-kit image, one as OCF Client, other is OCF Server.
  2. Run this server led.js on the server board, and run this client.js on client board:
    
    client.js

var client = require( 'iotivity-node' ).client;

// Error handler function errorHandler(error) { console.log(error.message + JSON.stringify( error, null, 4 ) ); }

// Add error event listener. client.on("error", errorHandler);

client.on( "resourcefound", function( resource ) { console.log(resource); } ) .findResources() .then( function() { console.log( "find" ); }, function( error ) { console.log( 'Failed'); } );


BTW, when running the client.js to discovery resource, it always enter the function errorHandler and print the error as below:

indResources: Unexpected response{ "response": { "devAddr": { "adapter": 2, "flags": 0, "ifindex": 0, "port": 0, "addr": "" }, "addr": { "adapter": 2, "flags": 0, "ifindex": 0, "port": 0, "addr": "" }, "connType": 131072, "identity": [], "result": 255, "sequenceNumber": 0, "resourceUri": "/oic/res", "rcvdVendorSpecificHeaderOptions": [] } }



**iotivity-node version**: 1.2.0-2
gabrielschulhof commented 7 years ago

@wanghongjuan please try to reproduce this problem with the latest version of iotivity-node and reopen this issue if the problem still exists!