Skip to content
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

Add DisconnectReason to ParticipantInfo. #788

Merged
merged 4 commits into from
Aug 13, 2024
Merged

Conversation

boks1971
Copy link
Contributor

@boks1971 boks1971 commented Aug 13, 2024

@lukasIO Last time, I did not create a changeset. Is there a specific step to create that? Do I need to run pnpm changeset in the repo?

Copy link

changeset-bot bot commented Aug 13, 2024

🦋 Changeset detected

Latest commit: d4cd579

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

💥 An error occurred when fetching the changed packages and changesets in this PR
Some errors occurred when validating the changesets config:
The package or glob expression "github.com/livekit/protocol" specified in the `fixed` option does not match any package in the project. You may have misspelled the package name or provided an invalid glob expression. Note that glob expressions must be defined according to https://www.npmjs.com/package/micromatch.

@boks1971 boks1971 requested review from a team and lukasIO August 13, 2024 05:57
@lukasIO
Copy link
Contributor

lukasIO commented Aug 13, 2024

Do I need to run pnpm changeset in the repo?

the command to add a changeset would be

pnpm changeset add

the CLI will guide you through the steps. For this repo it's best to select "all packages" to be affected by protocol changes.

@@ -131,6 +131,7 @@ message ParticipantInfo {
bool is_publisher = 13;
Kind kind = 14;
map<string, string> attributes = 15;
DisconnectReason disconnect_reason = 16;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any chance of potentially including insight in to whether the participant is attempting a reconnect ?
I think users have been asking about this in the past.

Copy link
Contributor Author

@boks1971 boks1971 Aug 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a transient state. Will think more about it. This reason would really be valid only when state = DISCONNECTED. Reconnect indication would be orthogonal I think. What's your thinking on how that should work?

Copy link
Contributor Author

@boks1971 boks1971 Aug 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking more about the reconnecting indication.

reconnect = 1 if successful should be (mostly) transparent. But, that is the case where server clearly knows there is an attempt to resume. Adding an indication for what should be transparent feels a bit odd.

A full reconnect looks like a new connection to the server. If the participant exists in the room and a full reconnect happens, server could indicate that the participant is attempting another connection (but that would not work in cloud if connecting to different node and that node does not have the old participant's remote participant, would require sending a message to check, but that would impact every join).

Would be good to see what users want and figure out how to do that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just wanted to raise the thought, but don't think it's a pressing thing. Don't remember hearing requests about this for a while now.

@@ -131,6 +131,7 @@ message ParticipantInfo {
bool is_publisher = 13;
Kind kind = 14;
map<string, string> attributes = 15;
DisconnectReason disconnect_reason = 16;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could it be set by SIP to indicate the call termination reason?

I'm thinking about the following mapping:

  • Hangup -> CLIENT_INITIATED
  • No response -> UNAVAILABLE (new)
  • Busy -> REJECTED (new)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. If that is Participant specific, I think it should be okay. Thoughts on that @davidzhao .

Currently, internally server has these reasons for participant close - https://github.com/livekit/livekit/blob/5d554867102d8b3bee6e8865a85cae5513c19c62/pkg/rtc/types/interfaces.go#L84 and it gets mapped to DisconnectReason here - https://github.com/livekit/livekit/blob/5d554867102d8b3bee6e8865a85cae5513c19c62/pkg/rtc/types/interfaces.go#L169.

We can make more participant close reasons and map them to reasons like you mention above.

We do have participant kind now. Maybe, each kind has more specific reasons.

Question: I do not know enough about how SIP participant works. How would the SIP participant be conveyed the reason for its close? Actually, I guess I should first learn how the SIP participant gets closed now.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently it just disconnects from the room as usual (or is remove from the room by API). So I'll need to update the SDK to expose the disconnect reason (or at least some of them).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it. Client leaving currently sends this

LeaveRequest leave = 8;
and server just marks it as client initiated leave. If clients are going to send a reason, we can update server to parse the reason and mark the proper reason (would be mapping from DisconnectReason -> ParticipantCloseReason and back to DisconnectReason, but that is okay 🙂 )

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can add these as new disconnect reasons for SIP.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @davidzhao .

@dennwc Please let me know when you add these to LeaveRequest. We can then change the server to do the mapping. Maybe call the reasons with a SIP_ prefix for UNAVAILABLE and REJECTED. I do not particularly like prefixing with specific like that, but the un-prefixed version is very generic. So, that could be confusing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah hangup makes sense.. but for the rest, how about keeping it the original SIP reasons instead of mapping? this way we wouldn't need to prefix either

No response -> NO_RESPONSE
Busy -> USER_BUSY (not sure about the USER_, just wanted to disambiguate from server busy)

@boks1971
Copy link
Contributor Author

@dennwc Going to merge this for now. We can add more reasons in a subsequent PR.

@davidzhao Please let us know if you have further thoughts on SIP disconnect reason Denys mentioned and if you have ideas on how to do that? Enhance DisconnectReason or a different method. That would involve client sending the reason with LeaveRequest, server interpreting it and plumbing that through.

@boks1971 boks1971 merged commit bbd53d6 into main Aug 13, 2024
3 checks passed
@boks1971 boks1971 deleted the raja_disconnect_reason branch August 13, 2024 09:02
@github-actions github-actions bot mentioned this pull request Aug 13, 2024
paulwe pushed a commit that referenced this pull request Aug 13, 2024
* Add `DisconnectReason` to `ParticipantInfo`.

* generated protobuf

* Add changeset.

* patch changeset

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants