jambonz / jambonz/node-client-ws

Coexisting with other WS handlers is broken by the patch to allow other handlers

Open
#21 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
3
Forks
5
PR merge metrics
No merged PRs in 30d

Description

This change:
https://github.com/jambonz/node-client-ws/blame/462b0245607a2f23cb6004179b8c70ec9040f541/index.js#L72
Adds back 404ing upgrade requests at paths that this library isn't interested in.

It looks like it was done as part of additional functionality to add the ability to specify external WSServers.

Whilst that functionality is great, it only works for static paths that are known at the time `makeService()` is initialised and it breaks existing code that installs it's own `server.on('upgrade', ...)` and processes it's own paths dynamically as this library now overwrites the response headers from those upgrades with a 404 if it has no interest in the path, causing any upgrades apart from its own to fail.

Can we compromise and leave this extra External WSS handling in for implementations that choose to use it, but remove the 404 as I believe this is redundant anyway. If all the upgrade hooks fall through because nobody is interested in starting a WebSocketServer to serve the connection attempt at a path, then the connection is rejected anyway in the httpServer fallback handler.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start in index.js around line 72 and trace makeService()'s server.on('upgrade') handling, including the external WSS logic and the httpServer fallback handler. Done means dynamically registered external handlers can process their own paths without the library overwriting their upgrade response, while the optional external WSS handling remains available.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
backend, networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.