xmppjs / xmpp.js

XMPP for JavaScript
ISC License
2.2k stars 375 forks source link

Subscriptions limited to 100? #786

Closed ShadowRanger closed 5 years ago

ShadowRanger commented 5 years ago

So my application manages a friends system which uses Tigase XMPP. I use the following code to accept a friend request when one is sent:

const jid = `${userId}@chat.dm.origin.com`;
xmpp.send(xml("presence", { type: "subscribed", to: jid }));
xmpp.send(xml("presence", { type: "available", to: jid }));

For some reason, I am only able to accept up to 100 friend requests for 1 Origin account. I know it shouldn't be like this because you can have hundreds, if not thousands of friends on Origin. I am not seeing any obvious issues or errors when trying to accept friend requests with 100 friends, it just doesn't have any effect sending the above presences.

Is there something I need to do to bypass this limit or something? Thanks in advance.

sonnyp commented 5 years ago

What makes you think it's a restriction of xmpp.js and not the server?

ShadowRanger commented 5 years ago

What makes you think it's a restriction of xmpp.js and not the server?

I am not entirely sure, which is why I thought I would bring it here to see if you had any idea what the cause would be. Be it XMPP protocol related or a server issue. I am basically replicating how Origin accepts friend requests, and it works there so I was hoping that there could be something I could do to allow me to accept more than 100.

sonnyp commented 5 years ago

How do you "detect" friend request? can you share the code?

Also look at your logs for anything suspicious like a stream error. You can share them too. I recommend using https://github.com/xmppjs/xmpp.js/tree/master/packages/debug

ShadowRanger commented 5 years ago

How do you "detect" friend request? can you share the code?

Also look at your logs for anything suspicious like a stream error. You can share them too. I recommend using https://github.com/xmppjs/xmpp.js/tree/master/packages/debug

Okay I have added debugging to it, and have just found the error I am getting:

⮈ <presence type="subscribe" xmlns="jabber:client" to="HIDDEN@chat.dm.origin.com" from="HIDDEN@chat.dm.origin.com"/>
⮊ <presence type="subscribed" to="HIDDEN@chat.dm.origin.com"/>
⮈ <presence type="error" xmlns="jabber:client" to="HIDDEN@chat.dm.origin.com" from="HIDDEN@chat.dm.origin.com"><error type="wait" code="500"><internal-server-error xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/><text xmlns="urn:ietf:params:xml:ns:xmpp-stanzas" xml:lang="en">Error 22001: unable to confirm invite from 'HIDDEN@chat.dm.origin.com' for 'HIDDEN@chat.dm.origin.com/tigase-1'</text></error></presence>

Here is how I listen for friend requests, with the accept function call being what I posted above:

xmpp.on("stanza", async stanza => {
    if (!stanza.is("presence")) return;

    const attributes = stanza.attrs;
    if (!attributes) return;

    if (attributes.type === "subscribe") {
        this.acceptRequest(attributes.from.split("@")[0]);
    }
});
sonnyp commented 5 years ago

Ok so it's a server error.

If you add an id to the presence you send, chances are you will get that id back with the error so you can identify which presence stanza triggered the error.

Please be more considerate in opening issues in the future. Make sure to properly debug and only open issues if you know it is related to xmpp.js.

If you need help with XMPP you can try https://xmpp.org/community/