conversejs / converse.js

Web-based XMPP/Jabber chat client written in JavaScript
http://conversejs.org
Mozilla Public License 2.0
3.06k stars 763 forks source link

Should attempt other connectivity option upon failure #2341

Open guusdk opened 3 years ago

guusdk commented 3 years ago

When Converse fails to connect to the XMPP server, it should attempt to reconnect using other connection configuration, if that's available.

For example, when using XEP-0156, other Links should be attempted, if the first one fails.

--- Want to back this issue? **[Post a bounty on it!](https://app.bountysource.com/issues/94536295-should-attempt-other-connectivity-option-upon-failure?utm_campaign=plugin&utm_content=tracker%2F194169&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://app.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F194169&utm_medium=issues&utm_source=github).
jcbrand commented 3 years ago

Can you provide more concrete details?

There already is code to switch between BOSH and websocket: https://github.com/conversejs/converse.js/blob/4e3a81d697493f43451d9977576cfb310fe9b4c1/src/headless/converse-core.js#L374

And both BOSH and websocket endpoints are taken from .well-know/host-meta.

Converse however doesn't support multiple websocket or BOSH endpoints. Is that the problem you're having

guusdk commented 3 years ago

I've noticed this problem on Ignite, which at the time of writing, has this in https://igniterealtime.org/.well-known/host-meta

<?xml version='1.0' encoding='utf-8'?>
<XRD xmlns="http://docs.oasis-open.org/ns/xri/xrd-1.0">
  <Link rel="urn:xmpp:alt-connections:xbosh" href="https://igniterealtime.org:443/http-bind/"/>
  <Link rel="urn:xmpp:alt-connections:websocket" href="wss://xmpp.igniterealtime.org:7483/ws/"/>
</XRD>

Converse seems to prefer the websocket link, which it tries, but fails to use (some kind of CORS issue, but I don't think that's relevant to the issue at hand).

When I configure Converse to not do discovery of connection methods, and specify a bosh_service_url that matches the endpoint of the bosh link above, Converse happily connects.

{
  "discover_connection_methods": false,
  "default_domain": "igniterealtime.org",
  "bosh_service_url": "https://igniterealtime.org:443/http-bind/"
}

This leads me to believe that Converse does not attempt all Links that are in .well-known/host-meta