diff --git a/README.md b/README.md index bd9385f..c24fc66 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,7 @@ XMPP Web can be installed: | `defaultMuc` | `APP_DEFAULT_MUC` | `null` | Autocomplete MUC address (ex: `conference.domain.ltd`) if user do not provide a full room jid (join & create) | `isStylingDisabled` | `APP_IS_STYLING_DISABLED` | `false` | Set to `true` for disable messages styling | `hasSendingEnterKey` | `APP_HAS_SENDING_ENTER_KEY` | `false` | If `true`, `Enter` key sends message, it adds new line otherwise (`Control`+`Enter` always sends message) +| `connectTimeout` | `XMPP_CONNECT_TIMEOUT` | `5000` | Timeout in ms before XMPP connection is considered as rejected | N/A | `XMPP_WS` | `"http://localhost:5280/xmpp-websocket"` | Websocket endpoint proxyfied by Nginx (on a docker installation) ## Credits diff --git a/docs/docker/998-update-local.js.sh b/docs/docker/998-update-local.js.sh index 3426130..35e6dbe 100755 --- a/docs/docker/998-update-local.js.sh +++ b/docs/docker/998-update-local.js.sh @@ -57,6 +57,10 @@ update_localjs() { sed -i -r "s|hasSendingEnterKey: false|hasSendingEnterKey: true|g" $localjs fi + if [ "$XMPP_CONNECT_TIMEOUT" != "" ]; then + sed -i -r "s|connectTimeout: 5000|connectTimeout: $XMPP_CONNECT_TIMEOUT|g" $localjs + fi + echo "done" } diff --git a/docs/docker/Dockerfile b/docs/docker/Dockerfile index 78515d6..1574c64 100644 --- a/docs/docker/Dockerfile +++ b/docs/docker/Dockerfile @@ -31,6 +31,7 @@ ENV APP_DEFAULT_DOMAIN=localhost ENV APP_DEFAULT_MUC= ENV APP_IS_STYLING_DISABLED=0 ENV APP_HAS_SENDING_ENTER_KEY=0 +ENV XMPP_CONNECT_TIMEOUT= ENV XMPP_WS=http://localhost:5280/xmpp-websocket EXPOSE 80/tcp diff --git a/docs/docker/Dockerfile-multiarch b/docs/docker/Dockerfile-multiarch index f8a9e6c..cba82c3 100644 --- a/docs/docker/Dockerfile-multiarch +++ b/docs/docker/Dockerfile-multiarch @@ -18,6 +18,7 @@ ENV APP_DEFAULT_DOMAIN=localhost ENV APP_DEFAULT_MUC= ENV APP_IS_STYLING_DISABLED=0 ENV APP_HAS_SENDING_ENTER_KEY=0 +ENV XMPP_CONNECT_TIMEOUT= ENV XMPP_WS=http://localhost:5280/xmpp-websocket EXPOSE 80/tcp diff --git a/public/local.js b/public/local.js index c67d385..795b2c2 100644 --- a/public/local.js +++ b/public/local.js @@ -16,4 +16,5 @@ var config = { // defaultMuc: 'conference.domain-xmpp.ltd', isStylingDisabled: false, hasSendingEnterKey: false, + connectTimeout: 5000, } diff --git a/src/services/XmppSocket.js b/src/services/XmppSocket.js index 0f9577b..255cf05 100644 --- a/src/services/XmppSocket.js +++ b/src/services/XmppSocket.js @@ -5,6 +5,7 @@ const transports = window.config.transports const resource = window.config.resource const defaultDomain = window.config.defaultDomain const defaultMuc = window.config.defaultMuc +const connectTimeout = window.config.connectTimeout function logError (error, defaultLevel) { const args = Array.prototype.slice.call(arguments, 2) @@ -71,7 +72,7 @@ export default { // connect client to XMPP server connect () { - const timeoutDuration = 5000 + const timeoutDuration = connectTimeout || 5000 let timeoutId = null const timeoutPromise = new Promise((resolve, reject) => { timeoutId = setTimeout(() => {