I searched for this and saw some references to HTTP-Kit. Surprisingly, no one mentions Jetty and WebSockets and Clojure, even though most static Compojure and Ring examples use Jetty as the server.
But I’m looking for what is easy and well supported, so I’m curious what might be the most common way to do this in Clojure? Assume I’m implementing a chat system, what should I use on the server to support WebSockets?
However, over the years I also realized that websockets are not that great, and I intend to move to a polling solution once I get a different (and faster) database.
We use the WebSocket stuff that’s in Ring itself on top of Jetty. Works very well in production, and Jetty is well-supported by observability platforms like New Relic (which http-kit is not, by the way).
Before Ring added WebSockets, we used the sunng97 adapter which supported WebSockets on top of Jetty. Before that we rolled our own via Java interop on top of Jetty.
What are the problems you perceive with websockets that you hope to solve by using polling? As far as I am aware, websockets are an improvement over polling? What kind of polling do you envision?
Websockets have state and imply more state in your app, which in itself is a liability. I’ve come to believe that stateless solutions are inherently better.
As for practical considerations, not every gateway/firewall supports websockets correctly. Some of them will time out your connections, resulting in hard to find bugs and unhappy customers. Firefox has a >10 year old bug, where if you download a file, it will break the websocket connection, which results in problems in my app.
Sente is a fantastic library, but if I could get rid of it, I would be happier: less code, less complexity, fewer dependencies, those are all good things.
Server-side support: I use http-kit for now, but if I ever consider switching to something else, websockets complicate the picture.
In Meyvn, there is a template for setting up both a Sente solution and a bleeding-edge websocket solution, ie. jetty 12 and the new Ring websocket protocols, so you can compare both and see what better fits your needs.