This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-06
Channels
- # aleph (15)
- # announcements (2)
- # babashka (121)
- # beginners (62)
- # biff (6)
- # cherry (2)
- # cider (51)
- # clerk (30)
- # cljs-dev (5)
- # clojure (77)
- # clojure-austin (2)
- # clojure-europe (10)
- # clojure-germany (6)
- # clojure-nl (1)
- # clojure-norway (19)
- # clojure-romania (1)
- # clojure-uk (3)
- # clojurescript (16)
- # core-typed (7)
- # cursive (17)
- # datomic (12)
- # deps-new (11)
- # emacs (7)
- # events (2)
- # fulcro (5)
- # honeysql (2)
- # hyperfiddle (32)
- # introduce-yourself (1)
- # jobs-discuss (2)
- # membrane (18)
- # missionary (2)
- # music (5)
- # polylith (7)
- # reagent (26)
- # releases (5)
- # testing (32)
- # tools-build (14)
- # tools-deps (7)
- # xtdb (8)
I have a question about websockets.
When I try to connect via Chrome then it seems to work.
I only render one element of hx-ext
:
document.querySelectorAll("[hx-ext]")
NodeList [ div ]
But if I try to use Firefox then I get three retries like this:It doesn't happen when I try to run eelchat example app (only one socket).
And it doesn't happen when I add the websocket to the parent div of the document too.
It also happens 10 times if I add hx-ext
to 10 items in my page.
But if I add it at the top level where it's sent to rum
then it opens three sockets and I'm not sure which ones are alive.
I think I found the problem. It's the problem with oob swap that I do. I replace the whole HTML and force the websocket to reopen. But it's weird that it doesn't reopen the WS on chromium.
It's weird that it doesn't reuse the connection. I "fixed" this bug (or at least located it for now) but the larger issue remains: How do I keep the websocket connection while the user is navigating through the page? It kind of solves the issue with release of the resources when the user goes into another part of the webpage. But then isn't it wasteful to create a lot of requests just because the user is clicking buttons? It works fine if the only part that should be responsive is the chat window. But what if I want to make every piece of data responsive? Then what? :thinking_face:
hm, that is interesting it works differently on chrome my initial thought is to use a single websocket connection per page, and then just let it reconnect when the user navigates to a new page. you'll already be doing one request to get the new page, and I'm not sure doing another websocket connection request would be that much more overhead :thinking_face: though it does seem like there should be a way to make the connection persistent across page navigation...
I was thinking to save a client's ID in session but what if user has multiple tabs? This means I can't do it.
Then I was thinking to generate a random header value somewhere in the body
element but then this header isn't included in the websocket request. It is included into form requests. This may be a bug as they claim that hx-headers
should be included everywhere. They're not included here.
Now I think about simply using a path parameter and generating a nonce per-page.
I don't want to open a connection per subscribable element on a page. This is silly.
And I guess I'll have to live with reopening of websockets on page navigation (chromium also does reopen the websockets upon navigation. So behavior is not that different).
P.S. I also am not sure already if behavior is really different on Chrome. It may have been my testing error. But in any way when the navigation reopens the WS then it seems like a waste :thinking_face:
And the fact that I can't include headers is sad.
I'll take a break from this.