jcelliott / turnpike

Go implementation of a WAMP (Web Application Messaging Protocol) client and router
MIT License
258 stars 88 forks source link

AutoBahn.js unable to establish a connection #11

Closed highway900 closed 11 years ago

highway900 commented 11 years ago

AutoBahn.js is unable to establish a connection with the turnpike server.

I can though establish a standard new WebSocket("uri") connection via the javascript console. I can also issue message to turnpike in WAMP and get correct responses from the server and in the example chat program.

The autobahn version is coming from http://autobahn.s3.amazonaws.com/js/autobahn.js

Any ideas? Not sure if this a Autobahn.js issue or a turnpike issue. As autobahn.js connects fine with the autobahn python implementation.

jcelliott commented 11 years ago

It could very well be a turnpike issue. It's still relatively new, but I am using it in a production environment. I just tested with that version of autobahn. It seems to work for me, so I added an example that uses autobahn.js. Can you get the example running on your setup?

highway900 commented 11 years ago

My example is not so different from your example. But alas your example does not work for either...

Simply running

ab.connect("ws://localhost:8080/ws", connect, disconnect);

returns WebSocket connection to 'ws://localhost:8080/ws' failed: Unexpected response code: 403 in the console. And in the browser for your example I get WAMP client disconnected: Connection could not be established. (3)

But if I do ws = new WebSocket("ws://localhost:8080/ws") this will connect. Then ws.send("[5, \"event:myevent1\"]") and turnpike will respond correctly.

highway900 commented 11 years ago

Ok so we can close this, because I was running the connection via a file open. Not serving the page from a http server.

The origin header was set to null. Thus the 403.

jcelliott commented 11 years ago

Glad you figured it out. I'm still working on improving turnpike, so let me know if you run into any other issues or have any feature requests.