Closed colinkahn closed 9 years ago
Hi Colin - thanks for the report - will take a look.
James
Hi Colin - I'm afraid Ring's default Jetty adapter doesn't have any support for websockets as yet (that I know of!). Chord currently supports http-kit, which is a drop-in replacement.
In the case of your 'foo' project, you can add start/stop functions as follows:
(:require [org.httpkit.server :as httpkit])
(defonce !server
(atom nil))
(defn start-server! []
(swap! !server
(fn [running-server]
(or running-server
(httpkit/run-server app {:port 8080})))))
(defn stop-server []
(swap! !server
(fn [running-server]
(when running-server
;; call the server to stop it
(running-server)
nil))))
and then call (start-server!)
from a 'main' function, if required.
James
@james-henderson thanks, that worked. Can you explain what makes my version require that and the example not? https://github.com/james-henderson/chord/blob/master/example-project/src/chord/example/handler.clj
Good question, and something that probably isn't particularly clear - the example uses the Frodo plugin, which is essentially the same as lein-ring but sets up an HTTP-kit server instead. We specify :frodo/config-resource "chord-example.edn"
in the project.clj, then set up the web server handler/port configuration in chord-example.edn.
James
Very good to know, thanks again!
I'm getting the same error seen in issues #23 #21 when I hit my
/ws
endpoint from cljs. Here is what my project look likes:Server:
https://github.com/colinkahn/foo/blob/8a40c80eba76797be7c94b6f4bcaded359fe75e7/src/clj/foo/core.clj
Client:
https://github.com/colinkahn/foo/blob/8a40c80eba76797be7c94b6f4bcaded359fe75e7/src/cljs/foo/core.cljs#L53-L55
Project:
https://github.com/colinkahn/foo/blob/8a40c80eba76797be7c94b6f4bcaded359fe75e7/project.clj
I'm running it using
lein cljsbuild auto dev
in one terminal andlein ring server
in another.