auto assume WebSocket protocol using location.protocol

This commit is contained in:
Nick Krecklow 2020-05-05 17:52:28 -05:00
parent 899c094cb1
commit cdb64f0ad8
No known key found for this signature in database
GPG Key ID: 5F149FDE156FFA94
4 changed files with 12 additions and 12 deletions

@ -28,8 +28,6 @@ You can see an up-to-date copy of the production branch running on https://minet
5. Run ```npm run build``` (this bundles `assets/` into `dist/`) 5. Run ```npm run build``` (this bundles `assets/` into `dist/`)
6. Run ```node main.js``` to boot the system (may need sudo!) 6. Run ```node main.js``` to boot the system (may need sudo!)
If your deployment is using **https**, you will need to modify line 13 in `assets/js/socket.js` to use `wss://` instead of `ws://`. Otherwise browsers may prevent the WebSocket connection as it would be insecure on a secured connection.
(There's also ```install.sh``` and ```start.sh```, but they may not work for your OS.) (There's also ```install.sh``` and ```start.sh```, but they may not work for your OS.)
Database logging is disabled by default. You can enable it in ```config.json``` by setting ```logToDatabase``` to true. Database logging is disabled by default. You can enable it in ```config.json``` by setting ```logToDatabase``` to true.

@ -10,7 +10,12 @@ export class SocketManager {
} }
createWebSocket () { createWebSocket () {
this._webSocket = new WebSocket('ws://' + location.host) let webSocketProtocol = 'ws:'
if (location.protocol === 'https:') {
webSocketProtocol = 'wss:'
}
this._webSocket = new WebSocket(webSocketProtocol + '//' + location.host)
// The backend will automatically push data once connected // The backend will automatically push data once connected
this._webSocket.onopen = () => { this._webSocket.onopen = () => {

@ -3,8 +3,6 @@
- Frontend reconnect behavior has been improved to use exponential backoff behavior (up to 30 seconds) with unlimited retries. - Frontend reconnect behavior has been improved to use exponential backoff behavior (up to 30 seconds) with unlimited retries.
- The "Lost connection!" message will now show the reconnection attempt timer. - The "Lost connection!" message will now show the reconnection attempt timer.
If your deployment is using **https**, you will need to modify line 13 in `assets/js/socket.js` to use `wss://` instead of `ws://`. Otherwise browsers may prevent the WebSocket connection as it would be insecure on a secured connection.
**5.2.1** *(May 1 2020)* **5.2.1** *(May 1 2020)*
- The historical graph will now auto scale its yaxis steps. - The historical graph will now auto scale its yaxis steps.

@ -8,13 +8,12 @@ Minetrack 5 is the first of several upcoming updates designed to address several
4. Open the directory and execute `npm install --build-from-source`. This will install updated (and new) dependencies needed by the program. 4. Open the directory and execute `npm install --build-from-source`. This will install updated (and new) dependencies needed by the program.
5. If you have `logToDatabase: true` in your `config.json`, make sure to copy your `database.sql` file into the new directory, otherwise you will lose historical server activity and records. 5. If you have `logToDatabase: true` in your `config.json`, make sure to copy your `database.sql` file into the new directory, otherwise you will lose historical server activity and records.
6. Copy your existing `config.json` and `servers.json` files into the new directory. 6. Copy your existing `config.json` and `servers.json` files into the new directory.
7. If your deployment is using **https**, you will need to modify line 13 in `assets/js/socket.js` to use `wss://` instead of `ws://`. Otherwise browsers may prevent the WebSocket connection as it would be insecure on a secured connection. 7. Build your copy of `dist/`.
8. Build your copy of `dist/`. 8. If you have previously configured any `faviconOverride` values within `config.json`, you will need to move them to the updated structure. Create a new directory within your Minetrack folder named `favicons/`.
9. If you have previously configured any `faviconOverride` values within `config.json`, you will need to move them to the updated structure. Create a new directory within your Minetrack folder named `favicons/`. 9. If you have previously configured any `minecraft.json` values not included in the new `minecraft_versions.json` file, you will need to update their structure copy them to the new file.
10. If you have previously configured any `minecraft.json` values not included in the new `minecraft_versions.json` file, you will need to update their structure copy them to the new file. 10. Move your custom favicon images into the directory.
11. Move your custom favicon images into the directory. 11. Open `servers.json` in your favorite editor.
12. Open `servers.json` in your favorite editor. 12. For any server which you have a custom favicon, set the "favicon" field like so:
13. For any server which you have a custom favicon, set the "favicon" field like so:
``` ```
{ {