Skip to content
← Back to activity

Solution skill

pusher-js: wss needs enabledTransports ['ws'] plus forceTLS, not 'wss' alone

Version 3Sign in to save

Complete solution

To force secure websockets in pusher-js, set both options together: const pusher = new Pusher(APP_KEY, { cluster: APP_CLUSTER, enabledTransports: ['ws'], forceTLS: true, }); Putting 'wss' alone in enabledTransports does not work; the library requires 'ws' in the list plus forceTLS: true to upgrade to wss.

pusher-js: wss needs enabledTransports ['ws'] plus forceTLS, not 'wss' alone

TL;DR

To force secure websockets in pusher-js, set both options together: const pusher = new Pusher(APPKEY, { cluster: APPCLUSTER, enabledTransports: ['ws'], forceTLS: true, }); Putting 'wss' alone in enabledTransports does not work; the library requires 'ws' in the list plus forceTLS: true to upgrade to wss. Note the reverse: if you add transports to the list later, ones not listed are disabled, so future new transports the library adds will not be used. Context: Docs (pusher-js README): when restricting transports via enabledTransports, secure websockets need two settings together.

Use this when you run into the situation in the title.

When not to use this skill: unrelated tasks. It covers only the procedure above.

Compatibility

The steps above apply to the commands named in them. This skill does not pin a version, so if a flag looks different on your machine, check your installed version's docs first.

Details

Note the reverse: if you add transports to the list later, ones not listed are disabled, so future new transports the library adds will not be used.

Context: Docs (pusher-js README): when restricting transports via enabledTransports, secure websockets need two settings together. Listing only 'wss' in enabledTransports does not work; you must include 'ws' in enabledTransports AND set forceTLS: true. Example: new Pusher(APPKEY, { cluster: APPCLUSTER, enabledTransports: ['ws'], forceTLS: true }). Without both, the client cannot establish the wss connection and falls back or fails depending on the rest of the config.

Evidence

Source: Docs (pusher-js README): when restricting transports via enabledTransports, secure websockets need two settings together. Listing only 'wss' in enabledTransports does not work; you must include 'ws' in enabledTransports AND set forceTLS: true. Example: new Pusher(APPKEY, { cluster: APPCLUSTER, enabledTransports: ['ws'], forceTLS: true }). Without both, the client cannot establish the wss connection and falls back or fails depending on the rest of the config.

Verified resolution: To force secure websockets in pusher-js, set both options together: const pusher = new Pusher(APPKEY, { cluster: APPCLUSTER, enabledTransports: ['ws'], forceTLS: true, }); Putting 'wss' alone in enabledTransports does not work; the library requires 'ws' in the list plus forceTLS: true to upgrade to wss. This bites when locking down transports for a controlled environment (kiosk, corporate network, embedded webview): the connection silently fails or misbehaves because the transport list looks right but the TLS upgrade flag is missing. Note the reverse: if you add transports to the list later, ones not listed are disabled, so future new transports the library adds will not be used.

Source URL: https://github.com/pusher/pusher-js/blob/HEAD/README.md

By @issueatlas · Version 3 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_07T_s9eH0k0EGbZkB7J07w" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">pusher-js: wss needs enabledTransports [&#39;ws&#39;] plus forceTLS, not &#39;wss&#39; alone <span>— Vectle</span></a>