Skip to content
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

Ability to specify custom websocket ports #1071

Closed
tresf opened this issue Jan 11, 2023 · 5 comments · Fixed by #1263
Closed

Ability to specify custom websocket ports #1071

tresf opened this issue Jan 11, 2023 · 5 comments · Fixed by #1263
Assignees

Comments

@tresf
Copy link
Contributor

tresf commented Jan 11, 2023

Currently QZ Tray has its ports hard-coded (e.g. 8181), but certain use-cases (such as embedding it into another application) may prefer this to be changed to allow it to co-exist with QZ Tray proper.

public static final Integer[] WSS_PORTS = {8181, 8282, 8383, 8484};
public static final Integer[] WS_PORTS = {8182, 8283, 8384, 8485};
public static final Integer[] CUPS_RSS_PORTS = {8586, 8687, 8788, 8889};

Note: JavaScript already allows this:

tray/js/qz-tray.js

Lines 1085 to 1088 in b6849b2

* @param {Object} [options.port] Config options for ports to cycle.
* @param {Array<number>} [options.port.secure=[8181, 8282, 8383, 8484]] Array of secure (WSS) ports to try
* @param {Array<number>} [options.port.insecure=[8182, 8283, 8384, 8485]] Array of insecure (WS) ports to try
* @param {boolean} [options.usingSecure=true] If the web socket should try to use secure ports for connecting.

@tresf tresf self-assigned this Jan 11, 2023
@tresf
Copy link
Contributor Author

tresf commented Mar 16, 2024

My initial strategy was to tackle this as part of PrefsSearch, however this has the adverse side-effect of NOT installing the windows firewall rules, since the property is set dynamically at runtime and the Windows installer won't know about it.

  • Currently on our Company Branded portal, we do search/replace on certain branded fields. For the Windows installer to install the correct firewall rules, this same search/replace will likely be necessary, but this is a crude, brute-force technique and will make unit-testing harder.
  • An alternative option is to provide the ability for a property to be picked up during installation (similar to Provisioning support #1190). This is possible, but will require some additional thoughts/planning.

@tresf
Copy link
Contributor Author

tresf commented May 6, 2024

An alternative option is to provide the ability for a property to be picked up during installation (similar to Provisioning support #1190). This is possible, but will require some additional thoughts/planning.

The strategy I took instead was to do a look-ahead into the provisioning file so that this information would be availble at install time before hte qz-tray.properties file is created.

For usage, see https://qz.io/docs/command-line#system-properties, specifically:

Property Description Example
websocket.secure.ports Comma separated list of secure websocket (wss://) ports to use [8181,8282,8383,8484] (Since 2.2.4) java -Dwebsocket.secure.ports=9191,9292 -jar qz-tray.jar ...
websocket.insecure.ports Comma separated list of insecure websocket (ws://) ports to use [8182,8283,8384,8485] (Since 2.2.4) java -Dwebsocket.insecure.ports=9192,9293 -jar qz-tray.jar ...

... which can be set directly in qz-tray.properties if desired (restart required)

websocket.secure.ports=9191,9292
websocket.insecure.ports=9192,9293

... or via environment:

setx QZ_OPTS "-Dwebsocket.secure.ports=9191,9292 -Dwebsocket.insecure.ports=9192,9293"

Start QZ Tray and ensure that you can access the new about page at https://localhost:9191

Note: Any calls to qz.websocket.connect() must be updated:

qz.websocket.connect({port: {secure: [9191,9292], insecure: [9192,9293]}});

WARNING: If a firewall is active, you may need to whitelist the ports.

This feature will be available starting with QZ Tray 2.2.4.

@churchianity
Copy link

churchianity commented May 7, 2024 via email

@tresf
Copy link
Contributor Author

tresf commented May 7, 2024

Roughly when is 2.2.4, and therefore this feature expected to be available on the company-branded portal?

Company-Branded has access to features immediately, however baking custom ports directly into the installer is currently held behind a backlogged feature of provisioning to be written for our portal: https://qz.io/docs/provisioning

Mockup here, if curious.

@tresf
Copy link
Contributor Author

tresf commented May 7, 2024

What would the simplest method for shipping company-branded installers (to customers, not devs)

Probably using provisioning, once ready. Otherwise customers would have to edit the properties manually, which most end users would not be comfortable doing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants