From d6c63533a9fc2eac380e67802acae620921c8ac3 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 2 Mar 2022 15:48:55 +0100 Subject: [PATCH 1/4] Added logging when a subscription dialog is invalid --- package-lock.json | 2 +- package.json | 2 +- src/subscription.ts | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9e3f513c..6c9381cf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "webphone-lib", - "version": "0.2.19", + "version": "0.2.19-beta1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 5cba80b6..5288094d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webphone-lib", - "version": "0.2.19", + "version": "0.2.19-beta1", "description": "Webphone Lib", "author": "Open VoIP Alliance", "license": "MIT", diff --git a/src/subscription.ts b/src/subscription.ts index 902767f0..234889ac 100644 --- a/src/subscription.ts +++ b/src/subscription.ts @@ -2,6 +2,8 @@ import { SubscriptionStatus } from './enums'; export { Subscription } from 'sip.js'; +import { log } from './logger'; + /** * Parse an incoming dialog XML request body and return * the account state from it. @@ -14,6 +16,10 @@ export function statusFromDialog(notification: any): SubscriptionStatus | string const dialogNode = xmlDoc ? xmlDoc.getElementsByTagName('dialog-info')[0] : null; // Skip; an invalid dialog. if (!dialogNode) { + log.error( + `[blf] ${notification} \n did not result in a valid dialogNode`, + 'subscription.statusFromDialog' + ); return null; } From 7864a6786face705e19b2500bf6366bab3256a72 Mon Sep 17 00:00:00 2001 From: Patrick Date: Fri, 4 Mar 2022 09:10:53 +0100 Subject: [PATCH 2/4] Adjusted beta version --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 6c9381cf..38340412 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "webphone-lib", - "version": "0.2.19-beta1", + "version": "0.2.19-beta.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 5288094d..b8867250 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "webphone-lib", - "version": "0.2.19-beta1", + "version": "0.2.19-beta.1", "description": "Webphone Lib", "author": "Open VoIP Alliance", "license": "MIT", From 8eb1259b08807d6f797cd43e9f3f7698bf7549c5 Mon Sep 17 00:00:00 2001 From: Patrick Date: Fri, 4 Mar 2022 10:17:50 +0100 Subject: [PATCH 3/4] Added some more logging --- src/client.ts | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/client.ts b/src/client.ts index 3d68cb3c..d937634b 100644 --- a/src/client.ts +++ b/src/client.ts @@ -240,8 +240,7 @@ export class ClientImpl extends EventEmitter implements IClient { return new Promise((resolve, reject) => { if (this.subscriptions[uri]) { - log.info('Already subscribed', this.constructor.name); - + log.info(`[blf] Already subscribed to ${uri}`, this.constructor.name); resolve(); return; } @@ -251,17 +250,24 @@ export class ClientImpl extends EventEmitter implements IClient { this.subscriptions[uri].delegate = { onNotify: (notification: Notification) => { notification.accept(); - this.emit('subscriptionNotify', uri, statusFromDialog(notification)); + const status = statusFromDialog(notification); + log.debug( + `[blf] ${notification} \n accepted, emitting notify event with status ${status}`, + 'client.subscriptions.delegate.onNotify' + ); + this.emit('subscriptionNotify', uri, status); } }; this.subscriptions[uri].stateChange.on((newState: SubscriptionState) => { switch (newState) { case SubscriptionState.Subscribed: + log.info(`[blf] Already subscribed to ${uri}`, this.constructor.name); resolve(); break; case SubscriptionState.Terminated: delete this.subscriptions[uri]; + log.info(`[blf] subscription terminated for ${uri}`, this.constructor.name); this.emit('subscriptionTerminated', uri); break; } @@ -269,6 +275,7 @@ export class ClientImpl extends EventEmitter implements IClient { this.subscriptions[uri].on('failed', (response: Core.IncomingResponseMessage) => { if (!response) { + log.error(`[blf] subscription failed for ${uri}`, this.constructor.name); this.removeSubscription({ uri }); reject(); return; @@ -296,6 +303,7 @@ export class ClientImpl extends EventEmitter implements IClient { this.subscriptions[uri].subscribe(); }); } + public async resubscribe(uri: string): Promise { if (!this.subscriptions[uri]) { throw new Error('Cannot resubscribe to nonexistent subscription.'); From 7f68decd4846e7263962b8354375f4243c425f1a Mon Sep 17 00:00:00 2001 From: Patrick Date: Mon, 7 Mar 2022 09:30:29 +0100 Subject: [PATCH 4/4] log info -> debug --- src/client.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client.ts b/src/client.ts index d937634b..8ac0fcec 100644 --- a/src/client.ts +++ b/src/client.ts @@ -240,7 +240,7 @@ export class ClientImpl extends EventEmitter implements IClient { return new Promise((resolve, reject) => { if (this.subscriptions[uri]) { - log.info(`[blf] Already subscribed to ${uri}`, this.constructor.name); + log.debug(`[blf] Already subscribed to ${uri}`, this.constructor.name); resolve(); return; } @@ -262,12 +262,12 @@ export class ClientImpl extends EventEmitter implements IClient { this.subscriptions[uri].stateChange.on((newState: SubscriptionState) => { switch (newState) { case SubscriptionState.Subscribed: - log.info(`[blf] Already subscribed to ${uri}`, this.constructor.name); + log.debug(`[blf] Already subscribed to ${uri}`, this.constructor.name); resolve(); break; case SubscriptionState.Terminated: delete this.subscriptions[uri]; - log.info(`[blf] subscription terminated for ${uri}`, this.constructor.name); + log.debug(`[blf] subscription terminated for ${uri}`, this.constructor.name); this.emit('subscriptionTerminated', uri); break; }