aleph

gomosdg 2021-05-12T08:22:29.005400Z

I am trying to serve ws connection and html from a single controller using:

(d/catch
                        (http/websocket-connection req)
                        (fn [_] nil))

gomosdg 2021-05-12T08:22:52.005800Z

and serving html when conn is nil

gomosdg 2021-05-12T08:23:51.007100Z

But when it seems like aleph ends up getting the exception from http/websocket-connection anyways and instead of displaying my html it shows “expected websocket request” on the browser

gomosdg 2021-05-12T08:24:23.007400Z

The full handler:

(defn room-handler [req]
  (d/let-flow [room-id (get-in req [:params :room-id])
               username (get-in req [:session :identity])
               room (get @rooms room-id)
               conn (d/catch
                        (http/websocket-connection req)
                        (fn [_] nil))]

              (if conn
                (r/add-user! room {:username username
                                   :stream conn})
                (layouts/main (str "SDG Rooms - " (r/get-name room))
                              (r/get-view room)))))

2021-05-12T17:40:04.008500Z

the way websockets are usually handled (in netty, not sure about aleph) is you pick a specific url path (route) for websockets

2021-05-12T17:41:08.009500Z

my guess is the netty websocket stuff returns the “expected websocket request” instead of throwing any kind of exception