Hi, An update... I hope I was able to narrow down the issue.
It's related to the calls to cancelObserve() method on the resource managed by the cloud. In my application flow, once a GUI form is being opened, I discover the resource, register for notifications using OcResource.observe() method, and keep updating the GUI. When closing the form, I de-register using *OcResource.cancelObserve()*. *From that point, OcPlatform.findResource() stops working, and reports exception.* When I modify the code by not calling cancelObserve() - findResource() keeps working.. But it's a leak so it's hardly an appropriate solution. aircon_controller.cpp sample does not use cancelObserve() so the problem cannpt be reproduced using it without modification. Anyone can share an idea on how to debug this issue amy further? Thanks Max. On Mon, Dec 18, 2017 at 10:54 AM, Max Kholmyansky <[email protected]> wrote: > Hi, > > I am implementing a client (using Java DSK) discovering resources via > IoTivity cloud. > > After a successful sing-in to the cloud, I manage to discover the > resources from the cloud. However, a* second attempt to perform the > resource discovery* from the cloud - always results in *UNAUTHORIZED_REQ* > exception. > > *Is it by design? Is there a requirement to peform sign-in before every > resource discovery request?* > > > More details about the issue... > > I use version 1.3.1 with Java SDK. > > The flow of my code: (trying to mimic the aircon_controller.cpp sample) > > private final String cloudEndPoint = "coap+tcp://[myipaddr]:[myport]"; > > accountManager = OcPlatform.constructAccountManagerObject(cloudEndPoint, > EnumSet.of(OcConnectivityType.CT_ADAPTER_TCP)); > > accountManager.signIn(sid, token, new OcAccountManager.OnPostListener() // I > get a success callback > > // The 1st call to findResource always succeeds > > OcPlatform.findResource( > > cloudEndPoint, > > "/oic/res", > > EnumSet.of(OcConnectivityType.CT_ADAPTER_TCP, > OcConnectivityType.CT_IP_USE_V4), > > new OcPlatform.OnResourceFoundListener() ) // getting a success at > the 1st call > > *// Problem: from here, every time I repeat the call to > OcPlatform.findResource() - it fails with exception UNAUTHORIZED_REQ* > > > I would appreciate an input on how to resolv this issue in the right way. > > > Thanks in advance > > Max > > > > > -- > Max Kholmyansky > Software Architect - SURE Universal Ltd. > http://www.sureuniversal.com > >
_______________________________________________ iotivity-dev mailing list [email protected] https://lists.iotivity.org/mailman/listinfo/iotivity-dev
