Hi Tim, I think I went through this when I was first starting with Sente. You need to setup the CSRF handling part, in the example code by including ring-anti-forgery/wrap-anti-forgery in your routes. *AND* you have to make sure that you are using one of those routes before you try to use Sente's connection stuff, otherwise your session won't have certain critical attributes set (e.g. __anti-forgery-token). I think the 404s are from the anti-forgery stuff rejecting your request. And I think Sente is assuming it's setup. This was a while ago so maybe I'm not remembering it quite right.
Cheers, Bob On Jul 26, 2014, at 12:33 AM, Timothy Washington <twash...@gmail.com> wrote: > Hi all, > > I'm using [com.taoensso/sente "0.15.1"], 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 > > > -- > 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. -- 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.