Fork me on GitHub
#yada
<
2016-03-11
>
Macroz08:03:32

websocket "just works" for me?

Macroz08:03:50

with route e.g. ["/ws" websocket-handler]

Macroz08:03:38

websocket-handler being simply something like

(defn websocket-handler [req]
 (let [s @(http/websocket-connection req)]
    ...))

nha08:03:36

Where "/ws" matches the protocol ?

Macroz08:03:05

it's just a route that I wanted to use

Macroz08:03:16

if you inspect the req it has all the proper websocket headers

Macroz08:03:24

and therefore you can do that websocket-connection call

Macroz08:03:41

at the moment I'm not in CORS land yet though

nha08:03:08

Alright I must be missing something :

ERROR yada.handler - Internal Error
clojure.lang.ExceptionInfo: Error on GET
	at clojure.core$ex_info.invoke(core.clj:4593)
	at yada.methods$eval51964$fn__51971$fn__51982.invoke(methods.clj:201)
	at manifold.deferred$catch_SINGLEQUOTE_$fn__41034.invoke(deferred.clj:962)
	at manifold.deferred.Listener.onError(deferred.clj:220)
	at manifold.deferred.Deferred$fn__40807$fn__40808.invoke(deferred.clj:400)
	at clojure.lang.AFn.run(AFn.java:22)
	at io.aleph.dirigiste.Executor$Worker$1.run(Executor.java:62)
	at manifold.executor$thread_factory$reify__40192$f__40193.invoke(executor.clj:36)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.lang.Thread.run(Thread.java:745)
ERROR yada.handler - ex-data: {:response <#C0702A7SB>.context.Response{:headers {"www-authenticate" [""]}, :vary #{:media-type}, :produces {:media-type <#C0702A7SB>.media_type.MediaTypeMap{:name "application/edn", :type "application", :subtype "edn", :parameters {}, :quality 0.9}, :charset <#C0702A7SB>.charset.CharsetMap{:alias "UTF-8", :quality 1.0}}}, :resource clojure.lang.PersistentArrayMap, :error #error {
 :cause nil
 :via
 [{:type java.lang.NullPointerException
   :message nil
   :at [backend.routes.api.sente$connect$fn__70359 invoke "sente.clj" 39]}]
 :trace

nha08:03:44

But good to know that is works for you simple_smile

nha08:03:40

Just to be sure : there is nothing special to match ws:// in your routes. right ?

nha08:03:01

My problem is that my handler is not called right now..

Macroz08:03:46

nothing special at all

Macroz08:03:02

but CORS can prevent the call of course

nha08:03:27

It shouldn't on GET I think. But my mistake - my handler is called ! Thanks simple_smile

nha16:03:59

What is the way to launch the yada examples ? Right now with lein I am getting a dependency error, ultimately trying to run this SSE example :

nha16:03:41

I am asking because I have a SSE route that seemed to work - ie. putting the URL in the browser returned a stream of data. But asking the same url via "real" event sourcing in JS shows a "canceled" request in Chrome, and the onerror event is triggered (but no message).

nha16:03:27

Ah I was returning a 202 instead of a 200 - still need to get messages though