Closed tpitale closed 6 years ago
I think that non
means non-ack'd, but I'm still learning. I was sort of expecting there to be a got_non({out, Message})
or something for when the responder is done with handle_request
or something.
Or if non
means there is no response at all. What would be the normal exit state of the transport? I can't seem to find how it would timeout from this phase.
NON means "Non-confirmable" message per CoAP RFC. NON (from the transport level) does not have any response. It's just one-shot message. The transport level is terminated on timeout (see timeout_after).
So timeout_after
goes to the channel
which calls back to coap_transport:timeout
with an Event
and the state of the transport. This goes here: https://github.com/gotthardp/gen_coap/blob/master/src/coap_transport.erl#L41-L42
Which would call got_non({timeout …
I think?
Random/related question: does pack
=> "peer ack" and aack
=> "application ack"?
I wrote it more than a year ago, so I don't remember everything, but yes, pack => "peer ack" and aack => "application ack"
got_non({timeout …
doesn't appear to be in coap_transport
. I may not know enough erlang to know that something else might catch this function call?
Both NON and CON timeout at the transport level via the "transport" timeout handled on the beginning of the file https://github.com/gotthardp/gen_coap/blob/master/src/coap_transport.erl#L59 https://github.com/gotthardp/gen_coap/blob/master/src/coap_transport.erl#L38
I see in idle
there is a timeout_after
for the atom transport
. Which goes to timeout(transport, _State)
and returns undefined
.
So … does the transport just terminate when the channel does?
The transport terminates itself after the lifetime timeout.
I just realized that the transport itself isn't a gen_server
. The inclusion of state in the functions had me thrown for a bit there 😄.
So when undefined
is returned, the channel no longer has state for the transport here: https://github.com/gotthardp/gen_coap/blob/master/src/coap_channel.erl#L137-L142
Make sense now, thank you for being so patient!
Oh yes, it's not a gen_server, it's not even a process. When undefined is returned, it is removed from the dict and that's it. https://github.com/gotthardp/gen_coap/blob/master/src/coap_channel.erl#L184
Hey @gotthardp, I was looking at https://github.com/gotthardp/gen_coap/blob/master/src/coap_transport.erl#L80-L82 and trying to figure out how the
transport
gets out of thegot_non
phase, or how the transport "completes" otherwise.Would you be able to enlighten me on this? Thanks for the help.