问题
I am using xmpp.js as xmpp chat client inside react-native for both android+ios with MongooseIM as chat server. I want to implement stream management acks in the App. But according to the issue#540, xmpp.js doesn't officially support stream management for now. What can be the alternate to this?
I need the stream management module only to send/receive acks between c2s and s2s. Please guide.
回答1:
Stream Management, if not available in your client library of choice, is somewhat complex to implement - though definitely would be welcome by the open source community ;)
XMPP Ping is a simpler alternative to detect broken connections. It's available in a range of servers including MongooseIM and ejabberd. The idea is that any side of the connection sends a ping IQ - since IQs are standardised to require responses, if a response does not come in a predefined time interval, you can assume such a connection is dead. There's no protocol for message retransmission like with Stream Management, but if you're running with Message Archive Management (mod_mam
) all the messages should be stored safely anyway.
Alternatively, as somebody has suggested in the issue you link, you could switch to Stanza.io which supports XEP-198.
来源:https://stackoverflow.com/questions/53257285/how-to-use-stream-management-acks-in-xmpp-js-in-react-native-with-mongooseim