I am currently working on a project using the technologies mentioned in the thread title.
I got it all running from the browser (the application is hosted on heroku), but when I try to connect to the websockets from my Ionic 2 application, I always get an error establishing handshake.
2016-09-17T15:02:03.200133+00:00 app[web.1]: 2016-09-17 15:02:03,199 DEBUG Connection http.response!uvRVDyvolYEG did not get successful WS handshake.
2016-09-17T15:02:03.200498+00:00 app[web.1]: 2016-09-17 15:02:03,200 DEBUG WebSocket closed before handshake established
2016-09-17T15:02:03.169206+00:00 heroku[router]: at=info method=GET path="/1/" host=musicmashup-jukebox.herokuapp.com request_id=c46960d7-bb8f-45bf-b8be-5a934c771d96 fwd="212.243.230.222" dyno=web.1 connect=0ms service=7ms status=400 bytes=74
Now one idea was, that it could be a CORS problem. So I installed django-cors-middleware
in hope this could solve the problem - well it did not.
But I think the app does not add any headers to the Daphne server at all.
At the moment I have no idea anymore, if the problem is on the client or on the server side.
Has anyone experienced similar problems?
EDIT: Found out that websockets and CORS do not have anything to do with each other Why is there no same-origin policy for WebSockets? Why can I connect to ws://localhost? So my guess is, that the server may reject the origin header sent by the client. I will see if I can get my hands on the headers being sent
This issue was fixed in Daphne v.1.0.3 https://github.com/django/daphne/commit/07dd777ef11f5091931fbb22bdacb9e4aefea7da
You need to also update channels and asgi-redis if it's used.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With