-
Notifications
You must be signed in to change notification settings - Fork 424
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: UDP heartbeat(ping/pong) not available #723
Conversation
May I kindly ask you to provide the contents of this pull request in English. Also, a descriptive commit message is missing, and you might want to pick a committer user name that simplifies attribution to you. |
Good practice also is to include a recipe in the PR description how to reproduce the issue to be solved. |
@@ -384,7 +384,7 @@ coap_mid_t coap_session_send_ping(coap_session_t *session) { | |||
return COAP_INVALID_MID; | |||
if (COAP_PROTO_NOT_RELIABLE(session->proto)) { | |||
uint16_t mid = coap_new_message_id (session); | |||
ping = coap_pdu_init(COAP_MESSAGE_CON, 0, mid, 0); | |||
ping = coap_pdu_init(COAP_MESSAGE_CON, COAP_SIGNALING_CODE_PING, mid, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
COAP_SIGNALING_CODE_PING is only valid for TCP, not UDP, so existing code is correct.
As per https://datatracker.ietf.org/doc/html/rfc7252#section-4.3
Summarizing Sections 4.2 and 4.3, the four message types can be used
as in Table 1. "*" means that the combination is not used in normal
operation but only to elicit a Reset message ("CoAP ping").
For UDP, an empty request is sent (Ping), and the RST response acknowledges the Ping (Pong).
@@ -2956,7 +2956,7 @@ handle_signaling(coap_context_t *context, coap_session_t *session, | |||
if (session->state == COAP_SESSION_STATE_CSM) | |||
coap_session_connected(session); | |||
} else if (pdu->code == COAP_SIGNALING_CODE_PING) { | |||
coap_pdu_t *pong = coap_pdu_init(COAP_MESSAGE_CON, COAP_SIGNALING_CODE_PONG, 0, 1); | |||
coap_pdu_t *pong = coap_pdu_init(COAP_MESSAGE_ACK, COAP_SIGNALING_CODE_PONG, pdu->mid, 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As COAP_SIGNALING_CODE_PING is only for TCP it actually does not matter wheth the message type and message id are defined as these ar enot sent over a TCP connection because it is reliable.
Thank you, mrdeep1 I didn't read the RFC document carefully. After retesting, I determined that the Ping / Pong packet format of UDP was correct and didn't need to be modified. My problems are:
The reason, I think, is the function coap_session_disconnected in no set last_ping=0. |
If the client application does not have a nack handler, or does not destroy the existing session on receipt of COAP_NACK_NOT_DELIVERABLE, then your change to |
$ ./coap-client -v 7 -m put coap://127.0.0.1/example_data -K 30 [coap-server close] ========================================================================================= Jul 19 16:56:21.959 DEBG * 127.0.0.1:58904 <-> 127.0.0.1:5683 UDP : sent 4 bytes [coap-server open] ========================================================================================= ... No more heartbeats |
Your coap-client is non-standard - it repeats the PUT request somehow after the CoAP ping failure. It would be good to know what your actual changes are to coap-client to demonstrate the issue as well as separately update this PR with your corrected code changes (squashing everything into a single commit) and english description. |
@wfeii1980 I wonder if this PR is still pursued. As the PR has not been updated according to the feedback provided, I am inclined to close it and encourage you to open a new PR once it is clear how to resolve the issue you have encountered. Would this work for you? |
Closing as this PR seems to be obsolete. Please feel free to open a new PR at any time if you feel that your issue has not been addressed. |
解决的两个问题: