I am trying to serve ws connection and html from a single controller using:
(d/catch
(http/websocket-connection req)
(fn [_] nil))
and serving html when conn is nil
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
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)))))
the way websockets are usually handled (in netty, not sure about aleph) is you pick a specific url path (route) for websockets
my guess is the netty websocket stuff returns the “expected websocket request” instead of throwing any kind of exception