On a shaky connection I have noticed that SIP.Transport will sometimes output to the console that the websocket has disconnected and then a second later it will say that the websocket has reconnected. Sometimes this happens only once, but sometimes it happens in cycles of up to 15 times. Along with the messages about the websocket connection the current SIP.Session will emit a 'failed' event every time the websocket disconnects and the UA will emit a 'connected' event every time the websocket connects again. Most of the time the session isn't noticeably affected by the interruption and the call continues normally, but sometimes the websocket will be disconnected long enough for the call to drop. When the call drops in this manner there's no 'bye' emitted and it seems like the library still thinks that the session is still connected.
One question I have is why does the UA emit a 'connected' event every time while never emitting a 'disconnected' event?
The other is do you know of any way to determine if the session is actually still connected or not after a 'failed' event? Or would it be safest to just call bye() myself and force it to not reestablish a connection?
Below is the console log to show this occurring. Unfortunately I only captured the cycle happening once because I forgot to copy the console when it was happening continuously. The connect/disconnect cycle of the transport was the last eleven lines happening over and over.
I produced it using this jsfiddle, http://jsfiddle.net/kcrfefxe/26/.
"Thu Oct 02 2014 15:02:32 GMT-0400 (Eastern Standard Time) | sip.inviteclientcontext | emitting event accepted" sip.js:2762
"BigBlueButton call started" show:152
"Thu Oct 02 2014 15:02:32 GMT-0400 (Eastern Standard Time) | sip.invitecontext.mediahandler | stream added: undefined" sip.js:2762
"Thu Oct 02 2014 15:02:32 GMT-0400 (Eastern Standard Time) | sip.invitecontext.mediahandler | emitting event addStream" sip.js:2762
"Thu Oct 02 2014 15:03:04 GMT-0400 (Eastern Standard Time) | sip.transaction.ict | Timer B expired for INVITE client transaction z9hG4bK7586365" sip.js:2762
"Thu Oct 02 2014 15:03:04 GMT-0400 (Eastern Standard Time) | sip.transaction.ict | Timer M expired for INVITE client transaction z9hG4bK7586365" sip.js:2762
"Thu Oct 02 2014 15:03:04 GMT-0400 (Eastern Standard Time) | sip.transaction.ict | emitting event stateChanged" sip.js:2762
"Thu Oct 02 2014 15:03:04 GMT-0400 (Eastern Standard Time) | sip.ua | emitting event transactionDestroyed" sip.js:2762
"Thu Oct 02 2014 15:03:12 GMT-0400 (Eastern Standard Time) | sip.transport | WebSocket disconnected (code: 1000)" sip.js:2762
"Thu Oct 02 2014 15:03:12 GMT-0400 (Eastern Standard Time) | sip.ua | connection state set to 1" sip.js:2762
"Thu Oct 02 2014 15:03:12 GMT-0400 (Eastern Standard Time) | sip.inviteclientcontext | emitting event failed" sip.js:2762
"call failed with cause: Connection Error" show:146
"Thu Oct 02 2014 15:03:12 GMT-0400 (Eastern Standard Time) | sip.transport | trying to reconnect to WebSocket ws://my.server.com/ws (reconnection attempt 1)" sip.js:2762
"Thu Oct 02 2014 15:03:16 GMT-0400 (Eastern Standard Time) | sip.transport | connecting to WebSocket ws://my.server.com/ws" sip.js:2762
"Thu Oct 02 2014 15:03:16 GMT-0400 (Eastern Standard Time) | sip.ua | emitting event connecting" sip.js:2762
"Thu Oct 02 2014 15:03:16 GMT-0400 (Eastern Standard Time) | sip.transport | WebSocket ws://my.server.com/ws connected" sip.js:2762
"Thu Oct 02 2014 15:03:16 GMT-0400 (Eastern Standard Time) | sip.ua | connection state set to 0" sip.js:2762
"Thu Oct 02 2014 15:03:16 GMT-0400 (Eastern Standard Time) | sip.ua | emitting event connected" sip.js:2762
"WebSocket connected" show:83
Chad