jarohen / chord

A library designed to bridge the gap between the triad of CLJ/CLJS, web-sockets and core.async.
439 stars 40 forks source link

WebSocket connection to 'ws://localhost:8080/streaming' failed: Invalid frame header #49

Closed twashing closed 8 years ago

twashing commented 8 years ago

When making a websocket connection to my server, chrod/client.cljs:35 is giving me the error mssage.

WebSocket connection to 'ws://localhost:8080/streaming' failed: Invalid frame header

What does this mean and how can I fix it? Thanks.

jarohen commented 8 years ago

Hi there, thanks for reporting :) that's not one I've seen before, I'm afraid - would it be possible to post the code around it on client- and server-side so that I can repro?

twashing commented 8 years ago

Hey James,

I tried to set something up for you. Check out this branch. Ignore the current Usage docs and go to http://localhost:8080/index.html, after running this.

lein repl
=> (require '[beatthemarket.shell :as sh])
=> (require 'cljs.build.api)     ;; compile cljs
=> (cljs.build.api/build "src"
                        {:main 'beatthemarket.client.core
                         :output-to "resources/public/js/main.js"
                         :output-dir "resources/public/js"
                         :asset-path "js"})
=> (sh/start-server)

Are you seeing the same error I'm seeing? And am I just using chord incorrectly?

Thanks

jarohen commented 8 years ago

Hey, thanks for sending this through. I've managed to connect to your streaming handler using a Chrome extension (couldn't find index.html?) by changing the app definition to:

(def app
  (handler/site
   (compojure/routes
     (GET "/"           req (index-handler req))
     (GET "/streaming"  req ((wrap-websocket-handler streaming-handler) req))
     (route/resources "/")
     (route/not-found "Page not found"))))

The wrap-websocket-handler call checks whether the incoming request is a websocket upgrade request and, if so, performs the handshake, and puts the ws-channel into the request map.

Could you check whether your client-side app works with this change?

Cheers!

James

twashing commented 8 years ago

Ahh yes, that seems to have done the trick.

Thanks so much James. This helps a lot.

Tim

On Tue, May 10, 2016 at 2:08 PM, James Henderson notifications@github.com wrote:

Hey, thanks for sending this through. I've managed to connect to your streaming handler using a Chrome extension (couldn't find index.html?) by changing the app definition to:

(def app (handler/site (compojure/routes (GET "/" req (index-handler req)) (GET "/streaming" req ((wrap-websocket-handler streaming-handler) req)) (route/resources "/") (route/not-found "Page not found"))))

The wrap-websocket-handler call checks whether the incoming request is a websocket upgrade request and, if so, performs the handshake, and puts the ws-channel into the request map.

Could you check whether your client-side app works with this change?

Cheers!

James

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/jarohen/chord/issues/49#issuecomment-218292006

jarohen commented 8 years ago

No worries :)