Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

IceFailedHandling.js 5.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* global __filename */
  2. import { getLogger } from 'jitsi-meet-logger';
  3. import * as JitsiConferenceErrors from '../../JitsiConferenceErrors';
  4. import * as JitsiConferenceEvents from '../../JitsiConferenceEvents';
  5. const logger = getLogger(__filename);
  6. /**
  7. * This class deals with shenanigans around JVB media session's ICE failed status handling.
  8. *
  9. * If ICE restarts are NOT explicitly enabled by the {@code enableIceRestart} config option, then the conference will
  10. * delay emitting the {@JitsiConferenceErrors.ICE_FAILED} event by 15 seconds. If the network info module reports
  11. * the internet offline status then the time will start counting after the internet comes back online.
  12. *
  13. * If ICE restart are enabled, then a delayed ICE failed notification to Jicofo will be sent, only if the ICE connection
  14. * does not recover soon after or before the XMPP connection is restored (if it was ever broken). If ICE fails while
  15. * the XMPP connection is not broken then the notifications will be sent after 2 seconds delay.
  16. */
  17. export default class IceFailedHandling {
  18. /**
  19. * Creates new {@code DelayedIceFailed} task.
  20. * @param {JitsiConference} conference
  21. */
  22. constructor(conference) {
  23. this._conference = conference;
  24. }
  25. /**
  26. * After making sure there's no way for the ICE connection to recover this method either sends ICE failed
  27. * notification to Jicofo or emits the ice failed conference event.
  28. * @private
  29. * @returns {void}
  30. */
  31. _actOnIceFailed() {
  32. const { enableForcedReload, enableIceRestart } = this._conference.options.config;
  33. const explicitlyDisabled = typeof enableIceRestart !== 'undefined' && !enableIceRestart;
  34. const supportsRestartByTerminate = this._conference.room.supportsRestartByTerminate();
  35. const useTerminateForRestart = supportsRestartByTerminate && !enableIceRestart;
  36. const reloadClient = this._conference.restartInProgress && enableForcedReload;
  37. logger.info('ICE failed,'
  38. + ` enableForcedReload: ${enableForcedReload},`
  39. + ` enableIceRestart: ${enableIceRestart},`
  40. + ` restartInProgress: ${this._conference.restartInProgress},`
  41. + ` supports restart by terminate: ${supportsRestartByTerminate}`);
  42. if (explicitlyDisabled || (!enableIceRestart && !supportsRestartByTerminate) || reloadClient) {
  43. logger.info('ICE failed, but ICE restarts are disabled');
  44. this._conference.eventEmitter.emit(
  45. JitsiConferenceEvents.CONFERENCE_FAILED,
  46. JitsiConferenceErrors.ICE_FAILED);
  47. return;
  48. }
  49. const jvbConnection = this._conference.jvbJingleSession;
  50. const jvbConnIceState = jvbConnection && jvbConnection.getIceConnectionState();
  51. if (!jvbConnection) {
  52. logger.warn('Not sending ICE failed - no JVB connection');
  53. } else if (jvbConnIceState === 'connected') {
  54. logger.info('ICE connection restored - not sending ICE failed');
  55. } else {
  56. logger.info('Sending ICE failed - the connection did not recover, '
  57. + `ICE state: ${jvbConnIceState}, `
  58. + `use 'session-terminate': ${useTerminateForRestart}`);
  59. if (useTerminateForRestart) {
  60. this._conference.jvbJingleSession.terminate(
  61. () => {
  62. logger.info('session-terminate for ice restart - done');
  63. },
  64. error => {
  65. logger.error(`session-terminate for ice restart - error: ${error.message}`);
  66. }, {
  67. reason: 'connectivity-error',
  68. reasonDescription: 'ICE FAILED',
  69. requestRestart: true,
  70. sendSessionTerminate: true
  71. });
  72. } else {
  73. this._conference.jvbJingleSession.sendIceFailedNotification();
  74. }
  75. }
  76. }
  77. /**
  78. * Starts the task.
  79. */
  80. start() {
  81. // Using xmpp.ping allows to handle both XMPP being disconnected and internet offline cases. The ping function
  82. // uses sendIQ2 method which is resilient to XMPP connection disconnected state and will patiently wait until it
  83. // gets reconnected.
  84. // This also handles the case about waiting for the internet to come back online, because ping
  85. // will only succeed when the internet is online and then there's a chance for the ICE to recover from FAILED to
  86. // CONNECTED which is the extra 2 second timeout after ping.
  87. // The 65 second timeout is given on purpose as there's no chance for XMPP to recover after 65 seconds of no
  88. // communication with the server. Such resume attempt will result in unrecoverable conference failed event due
  89. // to 'item-not-found' error returned by the server.
  90. this._conference.xmpp.ping(65000).then(
  91. () => {
  92. if (!this._canceled) {
  93. this._iceFailedTimeout = window.setTimeout(() => {
  94. this._iceFailedTimeout = undefined;
  95. this._actOnIceFailed();
  96. }, 2000);
  97. }
  98. },
  99. error => {
  100. logger.error('PING error/timeout - not sending ICE failed', error);
  101. });
  102. }
  103. /**
  104. * Cancels the task.
  105. */
  106. cancel() {
  107. this._canceled = true;
  108. window.clearTimeout(this._iceFailedTimeout);
  109. }
  110. }