Hi, Looks like, I found a bug in observer code. I used CPP SDK for my application.
When the client(observer), goes away without notifying the server, the server still tries to send notifications. Since, the client is not longer available, the server receives communication failures and removes the observer from the list, by calling *OCStackFeedBack, *which internally calls the CPP wrapper code "*EntityHandlerWrapper*". Since the Resource and Request Handles are NULL in OCStackFeedBack, the application entity handler is never called. This results, in holding an invalid observer ID by the application. Any future observations sent by the Server, results in crashing the Server, as the observer ID held by the application is invalid. OCStackResult OCStackFeedBack(CAToken_t token, uint8_t tokenLength, uint8_t status) in switch case case OC_OBSERVER_FAILED_COMM: OIC_LOG(DEBUG, TAG, "observer is unreachable"); observer = GetObserverUsingToken (token, tokenLength); if (observer) { if (observer->failedCommCount >= MAX_OBSERVER_FAILED_COMM) { result = FormOCEntityHandlerRequest(&ehRequest, * (OCRequestHandle)NULL,* OC_REST_NOMETHOD, &observer->devAddr, * (OCResourceHandle)NULL,* NULL, PAYLOAD_TYPE_REPRESENTATION, OC_FORMAT_CBOR, NULL, 0, 0, NULL, OC_OBSERVE_DEREGISTER, observer->observeId, 0); if (result != OC_STACK_OK) { return OC_STACK_ERROR; } if (observer->resource && observer->resource->entityHandler) { * observer->resource->entityHandler(OC_OBSERVE_FLAG, &ehRequest,* * observer->resource->entityHandlerCallbackParam);* OCEntityHandlerResult EntityHandlerWrapper(OCEntityHandlerFlag flag, OCEntityHandlerRequest * entityHandlerRequest, void* /*callbackParam*/) std::map <OCResourceHandle, OC::EntityHandler>::iterator entityHandlerEntry; std::map <OCResourceHandle, OC::EntityHandler>::iterator entityHandlerEnd; { // Finding the corresponding CPP Application entityHandler for a given resource std::lock_guard<std::mutex> lock(OC::details::serverWrapperLock); entityHandlerEntry = OC::details::entityHandlerMap.find *(entityHandlerRequest->resource);* entityHandlerEnd = OC::details::entityHandlerMap.end(); } if(entityHandlerEntry != entityHandlerEnd) { // Call CPP Application Entity Handler if(entityHandlerEntry->second) { result = entityHandlerEntry->second(pRequest); } -Ravee -=-=-=-=-=-=-=-=-=-=-=- Links: You receive all messages sent to this group. View/Reply Online (#9794): https://lists.iotivity.org/g/iotivity-dev/message/9794 Mute This Topic: https://lists.iotivity.org/mt/23791382/21656 Group Owner: iotivity-dev+ow...@lists.iotivity.org Unsubscribe: https://lists.iotivity.org/g/iotivity-dev/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-