Open baw-benji opened 6 years ago
I found our version (slightly early than the tip) also was not working and have added a hack to get us over the line. See below. After the handler is invoked, we check to ensure it is not observable before deleting the interaction:
coap_main.c:620 (Just after calling Handler!)
// Add support for Client based requests with the Observer option
// Check if response has the Observe flag, and reset state.
// Ensure we don't remove original Request as it is required for token comparison!
if ((GetObserveOptionFromMsg(pIA->pRespMsg,&obsVal) == COAP_OK) && obsVal > 0)
{
pIA->State = COAP_STATE_WAITING_RESPONSE;
pIA->pReqMsg->Type = NON;
pIA->pReqMsg->Timestamp = hal_rtc_1Hz_Cnt();
RemoveObserveOptionFromMsg(pIA->pRespMsg);
CoAP_SetSleepInteraction(pIA, POSTPONE_WAIT_TIME_SEK);
CoAP_EnqueueLastInteraction(pIA);
} else {
CoAP_DeleteInteraction(pIA); //direct delete, todo: eventually wait some time to send ACK instead of RST if out ACK to remote reponse was lost
}
Was this ever resolved? I seem to be having the same issue still today.
No not to my knowledge. I'm using the workaround suggested by @nzfarmer .
Description
The client is requesting correctly with the observe option and getting an ACK from the server. But after the first CON from the server my callback (sendRequestCB) is called and the interaction is getting deleted. (@see: coap_main.c:handleClientInteraction) In return the client sends a RST instead of an ACK because he cannot find the previous deleted interaction. (@see: coap_main.c:CoAP_HandleIncomingPacket) The server removes the subscriber because he received a RST (Cancel Observation).
Client code