Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use ws4redis in a separate URL address? #184

Open
yguarata opened this issue Apr 12, 2016 · 4 comments
Open

How to use ws4redis in a separate URL address? #184

yguarata opened this issue Apr 12, 2016 · 4 comments

Comments

@yguarata
Copy link
Contributor

I use a proxy service (CloudFlare) that does not support websockets. A workaround is to have a separate address for the websockets (such as ws.myapp.com), that is not behind the proxy. I tested this configuration and noticed that ws4redis was able to connect and send messages to the server, however the messages from the server were not flowing back to the clients. No errors showed up.

Do you have any clue on this? What part of the code should I look for if it is necessary some modification?

Thanks.

@jrief
Copy link
Owner

jrief commented Apr 12, 2016

I'm not sure if this restriction applies to websockets as well, but Javascript sometimes applies a foreign origin policy.

@yguarata
Copy link
Contributor Author

No, it does not apply to websockets. =/

During my tests, I needed to modify the following line in order to change the websocket host:
https://github.com/jrief/django-websocket-redis/blob/master/ws4redis/context_processors.py#L13

Could this have an impact on the way messages are consumed from redis queue?

@yguarata
Copy link
Contributor Author

Just found the problem. It concerned with looking for session key in line https://github.com/jrief/django-websocket-redis/blob/master/ws4redis/wsgi_server.py#L54. In the case of cross domains (websocket domain != app domain), it is necessary to inform Django to use the same cookie for these domains, setting the variable SESSION_COOKIE_DOMAIN in settings.py. For instance: SESSION_COOKIE_DOMAIN = '.myapp.co'. For more information, please refer to http://www.pindi.us/blog/migrating-cross-domain-cookies-django.

However, I needed to perform some minor modifications in ws4redis context_processor and settings in order to make it work with cross domains. I intend to do a pull request soon.

@yguarata
Copy link
Contributor Author

This is fixed by pull request #185

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants