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

Using DWR with multi-tenants #252

Open
LiteWait opened this issue Dec 15, 2017 · 2 comments
Open

Using DWR with multi-tenants #252

LiteWait opened this issue Dec 15, 2017 · 2 comments

Comments

@LiteWait
Copy link

LiteWait commented Dec 15, 2017

We run a multi-tenant solution using diango_tenants supporting 1000's of tenants on a cluster of web servers. It seems obvious there is no support for multi-tenant solutions in DWR. My question is does it seems feasible that DWR could be modified to support this? I've pulled down Channels and managed to get it working by picking the host from web socket connect to anchor the instance on a particular DB schema and squirreling the tenant info in the channel session. DWR just seems cleaner than Channels, but if I can't pull off multi-tenant it is a non-starter. Other option would be to replace Redis in DWR with RabbitMQ which I sure would be a brutal pill to swallow! Thanks.

@jrief
Copy link
Owner

jrief commented Dec 15, 2017

If you run ws4redis you can dispatch the websockets by their session-id.
In general, I always suggest to use websockets from the server to the client, and pure Ajax the other way round. Then the server can decide to whom a message will go, session or group.

It might be, that I did not understand your question correctly.

@oortega
Copy link

oortega commented Feb 13, 2020

Hello @LiteWait could you run ws4redis with multi tenant?

Hello @jrief I am using django schemas and ws4redis, but it does not work subscribe user, it only works when it is broadcast and session.

Subscribe user I guess it does not work because each postgres schema has a list of users and I suppose that ws4redis does not know what schema the user is up to, do you know what I should modify so that the message is sent to the user of the schema that initiated the request?

I use this https://django-tenant-schemas.readthedocs.io/en/latest/

Here https://github.com/oortega/facturas_tenant
I have the example of chat you have on ws4redis but only broadcast works, subscribe user does not work

I have noticed that it only works subscribe user in the public scheme, in celery the same error happened to me but in the task I do this


from django.db import connection
connection.set_schema(schema)

and I can already consult the correct tenant, do you know how I can tell ws4redis to consult the correct tenant?

thanks.

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

3 participants