pathom-viz ws seems to be working:
yenda@desktop:~$ wscat --connect <ws://localhost:8240/chsk>
Connected (press CTRL+C to quit)
there is an expected error in the server since I just connect with no params:
WARN [com.wsscode.node-ws-server:60] - Unhandled request: %s /.websocket
ERROR [taoensso.sente:628] - Client's Ring request doesn't have a client id. Does your server have the necessary keyword Ring middleware (`wrap-params` & `wrap-keyword-params`)?: {:websocket? true, :websocket #object[WebSocket [object Object]], :response nil, :body #object[IncomingMessage [object Object]], :query-params {}, :form-params {}, :params {}}
I tried the simplest possible connection on cljs side with:
(let [{:keys [chsk ch-recv send-fn state] :as res}
(sente/make-channel-socket-client!
"/chsk" ; Note the same path as before
"not needed"
{:host "localhost" :port 8240 :type :auto ; e/o #{:auto :ajax :ws}
})]
(println :res res)
(def chsk chsk)
(def ch-chsk ch-recv) ; ChannelSocket's receive channel
(def chsk-send! send-fn) ; ChannelSocket's send API fn
(def chsk-state state) ; Watchable, read-only atom
)
no reaction on server side and the ws stays in closed state
I noticed in res that the url has no host
(let [;; Not available with React Native, etc.:
win-loc (enc/get-win-loc)
path (or path (:pathname win-loc))]
(if-let [f (:chsk-url-fn opts)] ; Deprecated
[(f path win-loc :ws)
(f path win-loc :ajax)]
(let [protocol (or protocol (:protocol win-loc) :http)
host (if port
(str (:hostname win-loc) ":" port)
(do (:host win-loc)))]
[(get-chsk-url protocol host path :ws)
(get-chsk-url protocol host path :ajax)])))
unless I'm misunderstanding it looks like sente ignores the host and uses win-loc instead?
Looks like there is a bug in sente that is fixed in the next version, so I tried the newer version but it still doesn't connect
I am running this in nodejs
ok looks like I had to yarn add websocket
to my project
very useful, thanks!
done, also fixed the example to use cond->>
, thanks for pointing those out