Hi all,

I'm using [com.taoensso/sente "0.15.1"
<https://github.com/ptaoussanis/sente>], and having trouble connecting the
client to the server. I'm sure it's something simple, but not obvious, as
this is taken directly from the examples on sente's github page. Anyone
seen and fixed the error in fig.1? The clojurescript and clojure code are
in fig 2 and 3 respectively.


WebSocket connection to 'ws://172.28.128.5:58269/chsk' failed: Error during
WebSocket handshake: Unexpected response code: 404
 WebSocket error: [object Event] VM1707:1689
 Chsk is closed: will try reconnect (8). VM1707:1689

fig.1 - Chrome network error message

(ns my.ns
  (:require-macros
   [cljs.core.match.macros :refer (match)] ; Optional, useful
   [cljs.core.async.macros :as asyncm :refer (go go-loop)])
  (:require
   ;;[clojure.browser.repl :as repl]
   [cljs.core.match] ; Optional, useful
   [cljs.core.async :as async :refer (<! >! put! chan)]
   [taoensso.sente :as sente :refer (cb-success?)]))


(let [{:keys [chsk ch-recv send-fn state]}
      (sente/make-channel-socket! "/chsk" {:type :auto})]

  (def chsk       chsk)
  (def ch-chsk    ch-recv)
  (def chsk-send! send-fn)
  (def chsk-state state))

(defn one []
  (chsk-send! [:some/request-id {:name "Rich Hickey" :type "Awesome"}]))


*fig.2 - my.cljs *


(ns my.http.ns
  (:require [compojure.core :refer :all]
            ...

            ;; Sente stuff
            [clojure.core.match :as match :refer (match)] ; Optional, useful
            [clojure.core.async :as async :refer (<! <!! >! >!! put! chan
go go-loop)]
            [taoensso.sente :as sente]))


(let [{:keys [ch-recv send-fn ajax-post-fn ajax-get-or-ws-handshake-fn]}
      (sente/make-channel-socket! {})]

  (def ring-ajax-post                ajax-post-fn)
  (def ring-ajax-get-or-ws-handshake ajax-get-or-ws-handshake-fn)
  (def ch-chsk                       ch-recv)
  (def chsk-send!                    send-fn))

...

(defn create-approutes [project-config browserrepl]

  (defroutes app-routes

    ;; Sente stuff
    (GET  "/chsk" req (ring-ajax-get-or-ws-handshake req)) ; tried both
ring-ajax-get-or-ws-handshake and *#'*ring-ajax-get-or-ws-handshake
    (POST "/chsk" req (ring-ajax-post                req))        ; same
here for trying both


    (GET "/" []
         (-> (ring-resp/response (with-browser-repl "index.html"
browserrepl))
             (ring-resp/content-type "text/html")))

    (route/resources "/" {:root "resources/public/"})
    (route/not-found "Not Found")))

*fig.3 - my.clj *


Tim Washington
Interruptsoftware.com <http://interruptsoftware.com>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to