strophe / strophejs-plugin-stream-management

4 stars 21 forks source link

error calling requestAcknowledgement, "Higher reported acknowledge count than unacknowledged stanzas." #2

Open eugeniumegherea opened 6 years ago

eugeniumegherea commented 6 years ago

Tried to implement message delivery ack requests and every time, requestAcknowledgement function was throwing error from line 230.

Upon investigating found out that xmlOutput function seems to not handle properly element tag name detection. Because of that, _unacknowledgedStanzas array is always empty

xmlOutput: function (elem) {
  // elem is a HTMLElement with iq, presence or message as root element
  var child;
  for (var i = 0; i < elem.children.length; i++) {
    child = elem.children[i];
    // this if will never be true because iq, presence and message
    // are never child elements, they are root elements
    if (Strophe.isTagEqual(child, 'iq') ||
      Strophe.isTagEqual(child, 'presence') ||
      Strophe.isTagEqual(child, 'message')) {
      this._increaseSentStanzasCounter(child);
    }
  }

  return this._originalXMLOutput.call(this._c, elem);
},

As a workaround, I wrapped initial elem in another HTMLElement and it seems to be working that way. Is this the intended way or am I missing something?

mayurtailor009 commented 5 years ago

@eugeniumegherea :- How to use strophejs-plugin-stream-management plugin in reactjs ? Can you please provide steps ?

zainulhasan commented 5 years ago

_originalXMLOutput

I am having the same issue. It will be very helpful if share your solution. Thanks

mailtosagar commented 5 years ago

Hi, I am using react and strophe. Strophe always available as a global object( window obect ). So What you can do is

  1. Link all the js file in HTML
  2. make a connection.js file in the component folder (or where you write all your components). export strophe and strophe builders from there. Like: export const strophe = window.Strophe; const conn = new strophe.Connection('http://localhost:5280/http-bind'); export const onlineStatus = () => window.$pres(); export const pres = (sendingDetails) => window.$pres(sendingDetails); export const msg = (sendingDetails) => window.$msg(sendingDetails); export const iq = (sendingDetails) => window.$iq(sendingDetails);
  3. Import and use any plugin strophe.plugin.function();