Skip to content

Commit

Permalink
Handle unknown signal messages from the server (#568)
Browse files Browse the repository at this point in the history
When we switched to using oneof in generated protobufs, it broke the ability to handle unknown signal messages from the server. This is due to the protobuf parser returning undefined for message field, versus a new value for $case.
  • Loading branch information
davidzhao authored Feb 2, 2023
1 parent b9cd661 commit 6e35f39
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/honest-bikes-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'livekit-client': patch
---

Fixed handling of unknown signal messages
6 changes: 5 additions & 1 deletion src/api/SignalClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,11 @@ export class SignalClient {
}

private handleSignalResponse(res: SignalResponse) {
const msg = res.message!;
const msg = res.message;
if (msg == undefined) {
log.debug('received unsupported message');
return;
}
if (msg.$case === 'answer') {
const sd = fromProtoSessionDescription(msg.answer);
if (this.onAnswer) {
Expand Down
4 changes: 2 additions & 2 deletions src/room/RTCEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -681,14 +681,14 @@ export default class RTCEngine extends (EventEmitter as new () => TypedEventEmit
return;
}

log.debug(`${connection} disconnected`);
log.warn(`${connection} disconnected`);
if (this.reconnectAttempts === 0) {
// only reset start time on the first try
this.reconnectStart = Date.now();
}

const disconnect = (duration: number) => {
log.info(
log.warn(
`could not recover connection after ${this.reconnectAttempts} attempts, ${duration}ms. giving up`,
);
this.emit(EngineEvent.Disconnected);
Expand Down

0 comments on commit 6e35f39

Please sign in to comment.