Open MawiraIke opened 4 years ago
The general answer to this is 'your endpoint isn't what you think it is'. That could mean the socket isn't what you think it is or more likely your routing isn't what you think it is.
If you are not using the defaults for some reason, you need to make your own handler and routes using hanasu-handlers
:
as shown here:
and used here: https://github.com/jsa-aerial/hanami/blob/cd7d66f80ac05d8769cbe85d91a0020bd9cb11cd/examples/basic_charts.clj#L31
Thank you for your reply and for the repo hanasu
, really love its simplicity.
The project I am working on uses a custom handler and I think it should work.
The :main-handler
is
(def main-ring-handler
(-> my-routes
(ring.middleware.defaults/wrap-defaults ring.middleware.defaults/site-defaults)
(wrap-cljsjs)
(wrap-gzip)))
where my-routes
is a compojure's defroutes
value:
(defroutes my-routes
(GET "/" req (response/content-type
{:status 200
:session (if (session-uid req)
(:session req)
(assoc (:session req) :uid (unique-id)))
:body (io/input-stream (io/resource "oz/public/index.html"))}
"text/html"))
...)
Started the server with
(srv/start-server 10666 :main-handler main-ring-handler)
Edit:
Changed the connection on Cljs to be (cli/open-connection "ws://localhost:10666/")
, to match the url "/". Getting an error of status code 200
Error during WebSocket handshake: Unexpected response code: 200
I get an unexpected response code error when I use
cli/open-connection
. The error is thrown inws/connect url {...}
atin
haslett.client.
The error thrown is
Expected behaviour
A connection to an already running clojure-side server would go through to enable sending of messages between both sides. The server starts successfully from the clojure side.
Actual behaviour
Error
Error during WebSocket handshake: Unexpected response code: 302
I am using aerial.hanasu v0.2.3 What could the problem be or is this an issue for haslett?