What is the most common way to implement WebSockets via Clojure?

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?

I’ve been using Sente (GitHub - taoensso/sente: Realtime web comms library for Clojure/Script) for my app (PartsBox, https://partsbox.com/) for the last 9 years or so, and have been quite happy with it. The library is excellent and very well maintained.

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.

1 Like

Yup - http-kit is what we use. We’ve used it for both websockets and SSE in the past on different projects.

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.

1 Like

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?

1 Like