-
Notifications
You must be signed in to change notification settings - Fork 375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Response to PING #629
Comments
After some trial and error I manage the ping using
but I don't known for sure if this is the right way to manage ping request |
Please note that an error reply is a correct ping response as it fulfils its purpose.
Is there any specific reason why answering with an error wasn't enough? I can imagine enabling ping namespace response in |
Hi @sonnyp I'm not an expert of XMPP but based on ping documentation https://xmpp.org/extensions/xep-0199.html if I received a ping message:
I must return a response like this:
I must return an error only if I don't support ping namespace:
Correct me if I say something wrong :) |
@Pistacchione you're right, my point is that answering a ping request with an error is considered a ping response anyway because it fulfils the purpose of the ping. Anyway, I will add ping response to |
This ping response as an error keeps happening, right? |
I tested this problem. It's bug is did not fixed. After some time to be disconnected. |
Was the ping response added to @xmpp/client? |
Up until v0.13.0, xmpp.js seems to respond with the error as discussed above. I put in place a ping-response implementation: client.on('stanza', (stanza) => {
// XEP-0199: XMPP Ping
if (stanza.is('iq') && stanza.attrs.type === 'get' && stanza.getChild('ping', 'urn:xmpp:ping')) {
client.send(
xml("iq", { from: stanza.attrs.to, to: stanza.attrs.from, id: stanza.attrs.id, type: 'result' })
);
}
}); This results in double response to the same ping: IN
<iq type="get" id="792-276" from="my-server" to="2cwdh9zdl8@my-server/2cwdh9zdl8"><ping xmlns="urn:xmpp:ping"/></iq>
OUT
<iq from="2cwdh9zdl8@my-server/2cwdh9zdl8" to="my-server" id="792-276" type="result"/>
OUT
<iq to="my-server" from="2cwdh9zdl8@my-server/2cwdh9zdl8" id="792-276" type="error"><ping xmlns="urn:xmpp:ping"/><error type="cancel"><service-unavailable xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></iq> While this seems to be accepted by my XMPP Server (Openfire), it surely isn't pretty. |
@netmikey this is not how you're supposed to reply to iqs with xmpp.js. The solution is in #629 (comment) See https://github.com/xmppjs/xmpp.js/tree/main/packages/iq#callee |
Thanks for correcting me, @sonnyp! I had looked at the @xmpp/client documentation but had overseen the fact that iq handling is (understandably) documented in the iq package. |
Thanks. I think it should be prebuilt/by-default since it's in the spec. |
Hi,
I try to response a ping request, but every time the library sent this message:
How can I manage the ping?
The text was updated successfully, but these errors were encountered: