lukeed / lukeed/sockette

[Feature] Ability to set url before reconnecting

Open
#59 1 comment 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
2.5k
Forks
79
PR merge metrics
No merged PRs in 30d

Description

Right now in order to change websocket url you have to create a new instance of Sockette. This an issue for us because our url includes authorization token which expires after some time and when Sockette tries to reconnect it tries to reconnect using an expired token.

Here are a couple of possible solutions to this issue:

  1. getUrl config which can be set to a function which either returns a string directly or a Promise<string>. Sockette would use this function every time it tries to automatically establish websocket connection.
  2. setUrl() method on the Sockette class and ability to set onreconnect config to a function which returns a Promise. Sockette would wait for onreconnect promise to finish before it would try to reestablish connection.

@lukeed what do you think about it? Do you have any better suggestions?

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading Sockette's reconnect path and how it currently stores and uses the WebSocket URL. Compare the proposed getUrl and setUrl/onreconnect approaches, including asynchronous reconnect behavior, and confirm the intended API with the maintainer before changing anything. Done means reconnects can obtain a fresh authorization URL without creating a new Sockette instance, with coverage for the selected behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
networking
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.