-
Notifications
You must be signed in to change notification settings - Fork 511
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
Notify the cloud about planned disconnections #1899
Conversation
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.
All good changes! There are a few areas we need to complete:
-
documentation: the behaviour changes to cloud disconnect and system reset should be documented so that our users are aware of these changes.
-
opt-out: if the developer doesn't want to be sending disconnection reasons to the cloud, perhaps this can be opted out, e.g. via a system flag or feature.
How about we instead add a feature flags that disables graceful disconnections altogether? I don't see much sense in disabling Goodbye messages alone, but still waiting for other unacknowledged messages when disconnecting from the cloud |
f60ba5f
to
af85f03
Compare
I noticed that graceful cloud disconnection was implemented in 3 different places, 09ecec3c363555c9d57856bab4c734b4c1e9bf76 and 32b06be653f6b7dce0c0e9a76d631ce00c4fad94 address that |
db0dba9
to
0de6632
Compare
@m-mcgowan It is now possible to disable graceful cloud disconnection either globally (via the |
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.
opt-out: if the developer doesn't want to be sending disconnection reasons to the cloud, perhaps this can be opted out, e.g. via a system flag or feature.
How about we instead add a feature flags that disables graceful disconnections altogether? I don't see much sense in disabling Goodbye messages alone, but still waiting for other unacknowledged messages when disconnecting from the cloud
I was thinking to save data. But we can add it later if needed.
@m-mcgowan hm, yeah, that would make sense. I'm not entirely happy about the How about I ditch that flag and introduce another one which would disable goodbye messages specifically? |
I guess my main concern is that adding the goobye message adds two key behaviour changes:
When introducing features, it's not always clear how these changes impact customers. On the basis of this, I'm suggesting adding two flags: one to disable the goodbye message entirely and another to disable waiting for it (so it's sent as a non-confirmable CoAP message.) The state of these flags will be communicated to the cloud so that it knows the device is intentionally not saying goodbye when leaving. Irish Goodbye :-) |
It can be my dislike of overly configurable interfaces, but I'd keep it simple. If the overhead of this feature is not desirable, the users are free to disable it. Allowing it to be enabled but work unreliably feels like we're inventing extra work for ourselves.
That's a good point. I'll add a relevant flag to the Hello message 👍 |
959d9f6
to
0f73159
Compare
@m-mcgowan I added a system flag that enables/disables sending of Goodbye messages, as well as a Hello message flag that tells the cloud whether it should expect a Goodbye message from the device. Below is the summary of the changes since your last review:
|
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.
Looks good. 👍 Just some comments around clarification.
d58db7e
to
e74e4ad
Compare
e74e4ad
to
792200e
Compare
…he device to allow resetting the device immediately, without waiting for unacknowledged messages
…cribe message size; minor renamings"
aa847b6
to
58d9752
Compare
Problem
This PR implements a mechanism for graceful disconnection from the cloud on the following events:
System.reset()
,System.dfu()
and other APIs).Particle.disconnect()
.Upon any of the above events, the device first sends a Goodbye message to the cloud, waits for the message to be received by the cloud, and then proceeds to close the connection with the cloud. On UDP platforms the message is sent as a confirmable message and needs to be acknowledged by the server. On TCP platforms the delivery of the message is ensured by half-closing the socket and waiting for the server to close the connection.
The Goodbye message carries the information about the disconnection reason, system reset reason and duration of the sleep (if applicable). The format of the data is described here.
Important: This PR introduces the following changes in the current Device OS behavior:
System.reset()
and other APIs no longer reset the device immediately if it's connected to the cloud.This PR also refactors buffer appender classes (
BufferAppender
,BufferAppender2
), so that there's only oneBufferAppender
class.Steps to Test
app/cloud_disconnect
test app.References