Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

WebSockets rewrite

Open
#4 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Refactor
Clarity
Needs clarification
Activity status
Stale
Tech stack
javascript, nodejs, wordpress
Domain
api, backend

Research direction

Review the changes described for wsConnectUserToServer in api2.js, the wpIdentity WebSocket package switch, and the Caddy configuration shown in the issue. Check the server log and client behavior against the retry limits and WebSocket routing; done means failed connections no longer retry indefinitely or fall back to HTTP unexpectedly.

Written by the indexing model from the issue text.

Description

There have been problems over time with the WebSocket functionality in WordLand and wpIdentity. But I think I've gotten it stabilized, and since @scotthansonde was involved in this, a long time ago, I thought I should close the loop.

  1. I rewrote wsConnectUserToServer in api2.js to wait 10 seconds between retries after a failed connection, and to only try 100 times, and after that it gives up. You can reload the page to get another set of tries. Previously it waited 1 second and retried indefinitely.
  2. I switched the websockets package wpIdentity was using from nodejs-websocket to ws. This was based on advice I got from ChatGPT and Claude.ai, saying that nodejs-websocket was not being maintained, and the gold standard for everyone was ws.
  3. I changed the Caddy config file on the server, per the advice of ChatGPT, to make sure that failed WS connections didn't fall back to HTTP connections, which is what I was seeing in the logfile, along with the steady stream of errors in the user's JS console (this came up the other day in a bug report on the wordlandSupport repo issues list.

The result? It's much calmer in the server log. This is kind of mysterious, I didn't expect it to settle down so quickly because there must have been some old clients out there reconnecting every second?

The new Caddy file
{
  on_demand_tls {
    ask http://localhost:1339/isdomainvalid
  }
}

https:// {
  tls {
    on_demand
  }

  @websocketsWordlandSocial {
    host wordland.social
    header Connection *Upgrade*
    header Upgrade    websocket
  }

  @httpWordlandSocial {
    host wordland.social
  }

  reverse_proxy @websocketsWordlandSocial localhost:1502
  reverse_proxy @httpWordlandSocial localhost:1339

  # Optional: fallback for other domains
  reverse_proxy localhost:1339
} 

Screen shot of server log with a client trying to connect every second

Image

Dominant language
JavaScript
Stars
21
Forks
2
PR merge metrics
No merged PRs in 30d

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.

More from scripting/wpIdentity

All issues in scripting/wpIdentity

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.