uNetworking / uWebSockets.js

μWebSockets for Node.js back-ends :metal:
Apache License 2.0
7.76k stars 563 forks source link

Weird ws PubSub behaviour #950

Closed kinsi55 closed 1 year ago

kinsi55 commented 1 year ago

I'm not entirely certain if this bug is specific to the js wrapper but thats what I'm testing with.

I am on Node LTS (v18.17.0) and latest uWebSockets.js. My code is essentially the included Broadcast example with this as the open handler:

ws.subscribe("foo/wildcard/#");
ws.subscribe("foo/normal");

setTimeout(() => {
  ws.publish("foo/wildcard/bar", "broadcast ws");
  ws.publish("foo/normal", "normal ws");
}, 1000);

setTimeout(() => {
  app.publish("foo/wildcard/bar", "broadcast app");
  app.publish("foo/normal", "normal app");
}, 2000);

I would expect to receive 4 messages whenever I connect, however, in reality, all I receive is the bottom-most one

grafik

I spotted this issue because I'm building a new app and was trying to use a Wildcard subscribe, however never actually received anything that I publish. Eventually I figured out that Wildcards just seem to not work whatsoever, and while building this testcase also spotted that publishing on the ws doesnt work either for me.

e3dio commented 1 year ago

v20.0.0 - Massively simplified & improved pub/sub

Support for MQTT wildcards has been removed

kinsi55 commented 1 year ago

Oh, I see. Its been a while since I used uws last and I missed that that happened. I guess I'll have to figure out a workaround, thank you.

As a Sidenote, the PubSub example still includes Wildcards which is why I assumed it should just work