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

Clojure(!Script) Client Connection #20

Closed rydre closed 9 years ago

rydre commented 10 years ago

In Clojure, is there a way to open a websocket connection to a foreign server?

Thanks.

jarohen commented 10 years ago

Hi rydre - ClojureScript's websockets are subject to the same cross-origin security constraints as standard websockets. If you're using Clojure as the websocket client though (Chord doesn't support this, but I think http-kit does) there's no such restrictions.

I'm afraid I'm no expert on the exact cross-origin rules - I usually use the rule of thumb that it has to be the same domain, port and protocol to be allowed through, although I believe there may be some way of setting some response headers on your original response that allows JavaScript on the page to connect to other origins.

Some useful wikipedia pages might be:

James