Re: Can I use Django Channels to solve this architectural prolem?

2016-11-15 Thread Andrew Godwin
You could use channels (well, ASGI, it's lower-level interface) for the interconnect: - Use channels for signals from the web service to the controller daemon (maybe "service.stop" or "service.start" with the service name in the message payload). You can trigger these from simple AJAX or GET view

Re: I don't understand the second paragraph on the Getting Started with Channels documentation

2016-11-17 Thread Andrew Godwin
Yes, this means "once you have installed channels", since it's in the channels documentation. I'll update that line to mention "with channels". Andrew On Thu, Nov 17, 2016 at 2:13 PM, wrote: > When you run Django out of the box, it will be set up in the default >> layout - where all HTTP reques

Re: Can I use Django Channels to solve this architectural prolem?

2016-11-18 Thread Andrew Godwin
essage) directly from anywhere you want to send a message. Send is always non-blocking, but can raise ChannelFull - the spec linked above should cover the specifics. Andrew > > On Wednesday, 16 November 2016 06:51:19 UTC+1, Andrew Godwin wrote: > >> You could use channels (well, ASG

Re: Channels: startup order of daphne and workers leads to issues

2016-11-23 Thread Andrew Godwin
Hi Alex, It sounds like this isn't a daphne/workers ordering bug (things just queue and run when available) but a serialisability issue - that is, you expected `websocket.connect` to run before `websocket.receive` but in the released version they will run in parallel if both have queued messages.

Re: Structure for deploying django channels in producting in AWS

2016-11-27 Thread Andrew Godwin
Hi Vaisagh, You do not need nginx/apache in front of daphne to make it work (though it is usually a good idea to have it to serve static images, like you would with gunicorn). Have you tried connecting to the container directly locally from the host machine or from inside the container itself? Ha

Re: Django and asynchronous tasks

2016-11-30 Thread Andrew Godwin
Hi Alain, I'm not quite sure what you're trying to accomplish by mixing rq and channels; Channels just allows you to either write things against WebSocket connections, or to build your own eventing system from scratch on the same base code. If you're trying to return results to a webpage, you'll

Re: Channels, Websockets and 'Backpressure'

2016-12-01 Thread Andrew Godwin
"Backpressure" is designed exactly for what you describe, which is when clients are making requests of the server faster than you can handle them. Each channel has a maximum capacity of messages (100 by default), beyond which trying to add a new one results in an error. Webservers, when they see t

Re: Channels, Websockets and 'Backpressure'

2016-12-01 Thread Andrew Godwin
hing for 30 seconds. Hard failure is preferable in distributed systems in my experience; trying to solve the problem with soft failure and retry just makes problems even more difficult to detect and debug. Andrew > > On Thursday, December 1, 2016 at 12:34:22 PM UTC-8, Andrew Godwin wrote: >

Re: Channels, Websockets and 'Backpressure'

2016-12-01 Thread Andrew Godwin
On Thu, Dec 1, 2016 at 1:03 PM, Hank Sims wrote: > You set it in the channel layer configuration in Django, like this: >> https://github.com/django/asgi_redis/#usage >> > > Ah, thank you. Sorry I missed that. > > >> How would you propose this worked? The only alternative to closing the >> socket

Re: Websocket connection failed in production with Django-Channels

2016-12-05 Thread Andrew Godwin
For future reference, this discussion is also happening here: https://github.com/django/channels/issues/445 On Mon, Dec 5, 2016 at 2:04 AM, yass45 wrote: > Hello, > > > I try to use Django Channels on my website developed with Django 1.10 and > Python 3.5. This website is hosted on Webfaction. >

Re: how to customize ASGI ChannelLayer ?

2016-12-15 Thread Andrew Godwin
No, that's not what a channel layer is meant to do - it's for short term buffering (messages expire after a minute by default). I suggest you use a database. Andrew On 15 Dec 2016 17:53, "wang sheng" wrote: > I an developing a chat app, while some user is offline, I need to persist > the mess

Re: Understanding django channels persistant data

2016-12-20 Thread Andrew Godwin
On Tue, Dec 20, 2016 at 2:00 PM, Kakar Nyori wrote: > I am trying to grasp the concept of persistant data in django channels > . > I have searched the reference and other parts but didn't clear my > confusion. I would

Re: Understanding django channels persistant data

2016-12-20 Thread Andrew Godwin
On Tue, Dec 20, 2016 at 3:18 PM, Kakar Nyori wrote: > Wow, from the creator himself! Thank you. >> >> > Just so we're clear, *message.channel_session['key']* is the same as > *request.session['key']*, did I get you correctly? > It's very similar - the difference is that `request.session` lasts f

Re: Django Channels - WebSocket connection to 'wss://mysite.local/chat/stream/' failed: WebSocket is closed before the connection is established. response code: 200

2016-12-22 Thread Andrew Godwin
Apache's default mod_proxy does not support WebSockets. If you want to keep using Apache I would consider looking at mod_proxy_wstunnel. Andrew On Thu, Dec 22, 2016 at 2:24 PM, Adam Teale wrote: > Hi everyone, > > I have a django app running on mac os x server via mod_wsgi (apache 2.4). > > I a

Re: Django-Channels strange slowdowns - how to profile?

2016-12-29 Thread Andrew Godwin
Hi Jakub, There's no full profiling path yet - this is something I hope to work on as we start integrating ASGI code at work early next year. 400ms for a request is already very long; I'm slightly concerned by that (unless that's normal without Channels installed as well). If you want to do a ba

Re: How to pass data between Django module/app functions without using database in asynchronous web service

2016-12-29 Thread Andrew Godwin
Hi Ken, I'm mostly clear on what's happening here (you should definitely not use global variables for the reasons you mention), but I have a few questions to try and clear things up: - Are the websocket and the AJAX calls going to different clients/pages entirely, rather than them both being in t

Re: Django-Channels strange slowdowns - how to profile?

2016-12-30 Thread Andrew Godwin
rate about 80-100 rps. My last load tests showed that we >> can handle right now ~200, but sometimes (quite rarely) something goes bad >> and there is a major slowdown. It may be Docker fault, yesterday I found >> out that only one of our Daphne servers was used, others were idl

Re: How to pass data between Django module/app functions without using database in asynchronous web service

2017-01-01 Thread Andrew Godwin
e then > periodically download through websockets to a remote native compiled > application. > > > *On Thursday, December 29, 2016 at 6:00:03 AM UTC-5, Andrew Godwin wrote:* > >> *Q) - Could it potentially take the websocket client that is sending the >> LOBBY data

Re: How to send user specific data on Group().send() on Channels?

2017-01-02 Thread Andrew Godwin
> However, Group('online-users').send({'data': 'data'}) does not send the data to websocket.send channel. It sends the data directly over the WebSocket. It does, in fact, do exactly this - it seems you have got confused when you mention a consumer for the websocket.send channel, though, which is i

Re: How to send user specific data on Group().send() on Channels?

2017-01-03 Thread Andrew Godwin
On Mon, Jan 2, 2017 at 11:57 PM, Utku Gültopu wrote: > Then since I will be sending different data for every user, holding online > users in a single Group does not make sense right? > > But then where should I hold online users? In a database table? The > documentation states using a Group is th

Re: Django-Channels strange slowdowns - how to profile?

2017-01-03 Thread Andrew Godwin
e our own internal one. Andrew > > > On Friday, December 30, 2016 at 2:26:40 PM UTC+5:30, Andrew Godwin wrote: >> >> Wow, that's an incredibly slow network you have there. I would agree that >> you should move them all to the same place; I would say you want no more >&

Re: How to send user specific data on Group().send() on Channels?

2017-01-04 Thread Andrew Godwin
On Wed, Jan 4, 2017 at 3:22 AM, Utku Gültopu wrote: > It is for sending fresh data to users. Let's say user A follows users B, C > and D. However, only users A, B and C are online. Then only B's and C's > data should be sent to user A. Because user D's data would be stale. > > I thought of holdin

Re: Session key is empty after login on Django Channels development server

2017-01-08 Thread Andrew Godwin
Hi, Have you tried removing the "channels" package from INSTALLED_APPS and making sure it fails without that as well? Andrew On Sun, Jan 8, 2017 at 1:43 AM, Utku Gültopu wrote: > When I log a user in using django.contrib.auth.login function, session_key > is sometimes not set in the request of

Re: Sending messages to django channel group outside of consumers

2017-01-11 Thread Andrew Godwin
That code looks correct. What channel layer are you using? On Wed, Jan 11, 2017 at 2:55 PM, Gene wrote: > I'm trying to send messages to channels outside of consumers, as said in > documentation but can't get a result. > > For example, > in consumers.py I have: > > def channel_send(channel, data

Re: Sending messages to django channel group outside of consumers

2017-01-11 Thread Andrew Godwin
> I tried first with inmemory, then with asgi_redis.RedisChannelLayer > same result > working in runserver mode > > четверг, 12 января 2017 г., 2:06:15 UTC+3 пользователь Andrew Godwin > написал: >> >> That code looks correct. What channel layer are you using? >

Re: Sending messages to django channel group outside of consumers

2017-01-11 Thread Andrew Godwin
ion when runserver is launched > and I'm running in python manage.py shell ? > > in case I will not be able to find a solution, I'll try to reproduce it on > some special small project > > четверг, 12 января 2017 г., 2:11:16 UTC+3 пользователь Andrew Godwin > написал: &g

Re: Sending messages to django channel group outside of consumers

2017-01-11 Thread Andrew Godwin
Oh, disregard that, cross-checking with the django-channels IRC channel I see that it's the new message buffering behaviour going awry. You can track the status of the fix in https://github.com/django/channels/issues/481 On Wed, Jan 11, 2017 at 3:22 PM, Andrew Godwin wrote: > Yes, as

Re: Sending messages to django channel group outside of consumers

2017-01-11 Thread Andrew Godwin
fter accepting your patch it started to work! :-) >> >> четверг, 12 января 2017 г., 3:04:10 UTC+3 пользователь Gene написал: >>> >>> I managed to reproduce it in small project: >>> >>> see here test case: >>> https://github.com/emakarov/

Re: Django-channels connecting 2 random people

2017-01-14 Thread Andrew Godwin
Your best bet is probably to use a database to track who's currently got an open connection and their reply channel, and then use database rows to match pairs together (in another table). Your message received code can then look up the other side in the table and forward it to that reply channel.

Re: Django-channels connecting 2 random people

2017-01-15 Thread Andrew Godwin
o a > list of dictionaries and when 2 people are connected to remove them from > the list? And how can I guarantee that the channels limit is just 2 and > there won't be anyone joining by mistake? Or I just didn't get your idea. > Thanks for the spent time :) > > събота, 14 януа

Re: Channels - Unable to use redis as sharded cluster

2017-01-16 Thread Andrew Godwin
Hi Dadaso, You also opened this as a ticket on GitHub at https://github.com/django/channels/issues/485; I'll answer it there. Andrew On Mon, Jan 16, 2017 at 2:42 AM, Dadaso Zanzane < dadaso.zanz...@cuelogic.co.in> wrote: > Hi, > > I am using django channels for production. > > I have configured

Re: Experimenting with Channels: sending messages from Django shell doesn't work

2017-01-16 Thread Andrew Godwin
Hi Joshua, This was actually a bug that was fixed in 1.0.2 - were you on an older version? If not, I'd like to make sure the bug didn't somehow reappear! Andrew On Mon, Jan 16, 2017 at 10:00 AM, Joshua Gardner wrote: > I'm going to answer my own question: > > Appears that I need to use the "im

Re: Django Channels: send message on Group from worker process

2017-01-16 Thread Andrew Godwin
Hi Joren, This is a deliberate design decision; consumers (the things you have in views.py) are meant to not block and return immediately. Any blocking action, including delaying, needs to be done outside of the consumer and then send a message to invoke the next logic needed. This is because Cha

Re: Django channels, running uwsgi and awsgi

2017-01-18 Thread Andrew Godwin
On Wed, Jan 18, 2017 at 12:33 AM, Dev App wrote: > > I hope there 's a documentation how to do "running-asgi-alongside-wsgi" > https://channels.readthedocs.io/en/stable/deploying.html# > running-asgi-alongside-wsgi > (I tried google, but none found for how to do it) > > I'm just afraid to hand ov

Re: Django channels, running uwsgi and awsgi

2017-01-19 Thread Andrew Godwin
Nginx can't (to my knowledge) easily switch on the Upgrade header without extra modules as you need to take the header, lowercase it, and check it equals "websocket", and Nginx if statements are weird and limited in some important ways. Instead, I recommend you do prefix-based proxying, like this:

Re: Django-channels save reply channel to django model field?

2017-01-19 Thread Andrew Godwin
Hi, Channel isn't a field type - it's a separate datastructure entirely from a database/Django models and is powered by its own code and servers (the channel layer). If you want to persist the name of a reply_channel for use later, like knowing what channel connections are on to send information

Re: Django-channels and JSON-RPC

2017-01-19 Thread Andrew Godwin
I haven't seen anything like that personally, but I also don't see all of the Channels stuff going on, so maybe there is one. It would be relatively easy to implement as a single class-based consumer that dispatches to RPC handlers based on method name, though, as it matches the consumer pattern v

Re: Django-channels save reply channel to django model field?

2017-01-19 Thread Andrew Godwin
hod? > > четвъртък, 19 януари 2017 г., 20:25:41 UTC+2, Andrew Godwin написа: >> >> Hi, >> >> Channel isn't a field type - it's a separate datastructure entirely from >> a database/Django models and is powered by its own code and servers (the >> ch

Re: Django-channels and JSON-RPC

2017-01-20 Thread Andrew Godwin
On Fri, Jan 20, 2017 at 2:36 AM, Fabien Millerand wrote: > Thanks a lot for your answer Andrew. > > If you do end up implementing something, be sure to add it to the links page in the Channels docs (just submit a PR with the change) > On a side note, would you be related to Mike Godwin? I just

Re: how handle high incoming data and sending throttled data to web sockets in django-channels

2019-01-14 Thread Andrew Godwin
You'll have to design your own consumption architecture if you want to reliably handle 100 messages a second - since it's UDP, channels won't be handling it natively so you'll need to terminate and process the UDP yourself. I'd recommend either getting a UDP loadbalancer if you have messages coming

Re: Run Daphne as non-root on low ports

2019-05-02 Thread Andrew Godwin
Daphne does not have uid-changing built in, no - it's too simplistic for that, unfortunately. It's worth noting that systemd has this ability built in - it will listen on sockets for you and bind the socket to an application as needed. Otherwise, as the other poster noted, you can also use a rever

Re: Run Daphne as non-root on low ports

2019-05-02 Thread Andrew Godwin
e proxy with SSL termination at the > moment. > > On Thursday, May 2, 2019 at 9:49:41 AM UTC-4, Andrew Godwin wrote: >> >> Daphne does not have uid-changing built in, no - it's too simplistic for >> that, unfortunately. >> >> It's worth noting th

Re: Getting AttributeError: module 'asyncio' has no attribute '_get_running_loop'

2019-07-07 Thread Andrew Godwin
Hi Rohit, This is my fault - we made a change in the "asgiref" library that inadvertently removed Python 3.5 support. Channels still needs to support it (even though Django doesn't). If you update to asgiref 3.1.4, which I've just released, that should fix the issue. Andrew On Sun, Jul 7, 2019

Re: Getting AttributeError: module 'asyncio' has no attribute '_get_running_loop'

2019-07-08 Thread Andrew Godwin
ents mentioned in > requirements.txt > > Rohit > > On Sun 7 Jul, 2019, 9:36 PM Andrew Godwin, wrote: > >> Hi Rohit, >> >> This is my fault - we made a change in the "asgiref" library that >> inadvertently removed Python 3.5 support. Channels still nee

Re: Django-channels and JSON-RPC

2017-01-24 Thread Andrew Godwin
>>> écrit : >>>>> >>>>> If you are going to implement JSON-RPC based on Channels, I would be >>>>> happy to participate, I suppose we will start doing this in a few week >>>>> anyway. >>>>> >>>>> пятница, 20 январ

Re: Error connecting websocket with Django Channels

2017-01-24 Thread Andrew Godwin
Hi, I can confirm that the current answer on the page, by tovmeod, is the correct one - you must send back acceptance in connect as of channels 1.0. More here: http://channels.readthedocs.io/en/latest/releases/1.0.0.html#websocket-accept-reject-flow Andrew On Tue, Jan 24, 2017 at 8:48 AM, Shubha

Re: Django-channels and JSON-RPC

2017-01-24 Thread Andrew Godwin
> > >> I am not sure to understand. In which case can there be messages/frames > lost?! Where does that happen? Between the server interface and the Django > layer? I would need to know more about that... Otherwise I might need to > move with uWSGI or something JSON-RPC in itself doesn't implem

Re: Django-channels and JSON-RPC

2017-01-25 Thread Andrew Godwin
battle! Andrew On Wed, Jan 25, 2017 at 12:06 AM, Fabien Millerand wrote: > Ok, I start to understand now. > To be frank the docs are a bit alarming :) > > > > Le mercredi 25 janvier 2017 08:47:06 UTC+1, Andrew Godwin a écrit : >> >> >>>> I am not sure

Re: Django channels on IIS

2017-01-25 Thread Andrew Godwin
Hi, I am afraid I don't have experience using IIS - I don't know if it even supports HTTP/1.1 proxying, which is needed for WebSockets. Hopefully someone else can help. Andrew On Wed, Jan 25, 2017 at 6:35 AM, Алексей Кузуб wrote: > I have a project in Django and i want to use django channels f

Re: Django-channels and JSON-RPC

2017-01-26 Thread Andrew Godwin
t; work to be done for that. But if you want it for your next release it is > pretty much standalone. There is an example provided and plenty of tests. > > Let me know what you guys think, and if you see anything to be > modified/added. > > Cheers. > > Le mercredi 25 jan

Re: Django channels deployment

2017-01-26 Thread Andrew Godwin
Hi, Yes, you can run daphne with just an ASGI file that matches the Django settings. It's easier to just use the Django project for this, but you also don't need to update/restart it unless the CHANNEL_LAYERS setting changes. The conditions you put down are mostly correct, apart from 2), having o

Re: Django channels deployment

2017-01-26 Thread Andrew Godwin
ture with millions of requests :) ) > separate Redis server for the 1 customer? Can I dedicate some workers and > interface servers to just talk to specific Redis server? > > On Thursday, January 26, 2017 at 11:10:24 PM UTC+1, Andrew Godwin wrote: >> >> Hi, >> >>

Re: Django Channels alongside Django Rest Framework

2017-01-31 Thread Andrew Godwin
Hi Adam, The two should be able to coexist without any problem. If you put channels into INSTALLED_APPS then "runserver" is actually running Daphne already anyway, so it's worth noting if that's the case. You have two options: - Run everything via Daphne, which will serve both HTTP and WebSocket

Re: Channels - query_string

2017-02-01 Thread Andrew Godwin
Hi, You're right - a lot of the information only appears in the first "connect" message. If you want to persist it, you can use a channel session: http://channels.readthedocs.io/en/stable/getting-started.html#persisting-data This will let you save information (such as the token, or even a User obj

Re: Channels - query_string

2017-02-02 Thread Andrew Godwin
N > serializable. > What am I doing wrong? Should I somehow define how to JSON serialize the > User object? > > On Wednesday, February 1, 2017 at 7:01:47 PM UTC+1, Andrew Godwin wrote: >> >> Hi, >> You're right - a lot of the information only appears in the f

Re: Django-channels can't connect to websocket server. But when I am using redis I can't connect to my site at all.

2017-02-04 Thread Andrew Godwin
If you ever see "Unexpected response code: 200" it means that something between you and the server doesn't understand WebSockets. Given it's localhost in this case, have you installed channels and make sure it's in INSTALLED_APPS, then run `runserver`? Andrew On Sat, Feb 4, 2017 at 3:20 AM, Nikol

Re: Django channels

2017-02-04 Thread Andrew Godwin
"Dispatching message on websocket.receive to channels.routing.null_consumer" means that you don't have a consumer tied to the "websocket.receive" channel, so Channels is sending it nowhere. Did you set up your routing correctly? Andrew On Sat, Feb 4, 2017 at 2:41 AM, Алексей Кузуб wrote: > Hell

Re: Django channels

2017-02-05 Thread Andrew Godwin
ponse): > message.reply_channel.send(chunk) > > > def ws_message(message): > message.reply_channel.send({ > "text": message.content['text'], > }) > > > This is my code. And when I use http.request It's work! But when I try

Re: Django-channels can't connect to websocket server. But when I am using redis I can't connect to my site at all.

2017-02-05 Thread Andrew Godwin
eply_channel_a = reply_channel_name >> pair.reply_channel_b = user_topair.reply_channel_name >> pair.save() >> print(user_topair) >> user_topair.delete() >> >> else: >> # else put the user on the waiting list >>

Re: Django channels

2017-02-06 Thread Andrew Godwin
The errors you're getting both point to Channels not using your second two routes, but I've tried a similar routing locally and it works fine for me. Is there a chance you could make this into a small sample project that reproduces the issue? You could also try clearing any .pyc files or __pycache

Re: Django Channels: best way to launch multiple workers

2017-02-08 Thread Andrew Godwin
The difference is mostly in Python performance - threading in Python tends to perform worse than using multiple processes, which is why we recommend using multiple processes in the docs. However, you can save a bit of memory usage with threading, so you can use that if you want. I would not, howev

Re: Cannot install channels

2017-02-09 Thread Andrew Godwin
You don't have the Python development headers installed for your system - you can tell this because of this line in the error: src/twisted/test/raiser.c:4:20: fatal error: Python.h: No such file or directory If you install your distribution's python header package (e.g. on ubuntu it's python-dev)

Re: Cannot install channels

2017-02-09 Thread Andrew Godwin
ot require compilation. Andrew On Thu, Feb 9, 2017 at 11:10 PM, Robin Lery wrote: > Yes that was it. Thank you. Could you please help me understand why this > might have worked before in a earlier different virtual env in the same > vagrant machine? > > On Fri, Feb 10, 2017 a

Re: Django-channels disconnects right after sending a message

2017-02-21 Thread Andrew Godwin
How does it disconnect? What WebSocket close code do you get? (You'll need to add JS to log it) What prints on the Python console? Andrew On Tue, Feb 21, 2017 at 12:27 AM, Nikoleta Misheva wrote: > When I send message the websocket disconnects. I am able to get the > message, but I can't procee

Re: Django-channels disconnects right after sending a message

2017-02-21 Thread Andrew Godwin
console logs: > [2017/02/21 21:42:50] WebSocket DISCONNECT /play [127.0.0.1:65273] > [2017/02/21 21:42:50] WebSocket HANDSHAKING /play [127.0.0.1:65282] > It reconnects. > > > вторник, 21 февруари 2017 г., 20:45:13 UTC+2, Andrew Godwin написа: >> >> How does it disconnect? Wh

Re: Django-channels disconnects right after sending a message

2017-02-21 Thread Andrew Godwin
uot;); > socket.onmessage = function(e) { > alert(e.data); > } > socket.onopen = function() { > socket.send("hello world"); > } > > сряда, 22 февруари 2017 г., 3:08:09 UTC+2, Andrew Godwin написа: >> >> I'm afraid I don't really know what&

Re: Using Django Channels to subscribe to a Redis channel

2017-02-22 Thread Andrew Godwin
Hi Jochen, Your problem is that if you want to listen to the pubsub channel you will need a dedicated process to do so, as you can't just poll something like that. Given that restriction, you're going to have to write something like a management command that opens a connection to Redis and listens

Re: django channels in the shell

2017-02-22 Thread Andrew Godwin
I would recommend using the channel layer object directly instead in future: from channels.asgi import get_channel_layer channel_layer = get_channel_layer() That will make sure all settings are applied the same. Andrew On Wed, Feb 22, 2017 at 8:19 PM, chris rose wrote: > solved it.. I had to

Re: Daphne does not handle wss requests

2017-02-23 Thread Andrew Godwin
It looks correct - can you connect using https://127.0.0.1:8003/ at that point either? It's really odd that apparently the connection doesn't even happen at all. Andrew On Thu, Feb 23, 2017 at 2:55 AM, Giovanni Colapinto < giovanni.colapi...@gmail.com> wrote: > Hi. > > Before open a bug, could y

Re: Daphne does not handle wss requests

2017-02-24 Thread Andrew Godwin
017:08:05:25 > +] "GET /favicon.ico HTTP/1.1" 400 57588 "-" "Mozilla/5.0 (Windows NT > 10.0; WOW64; rv:53.0) Gecko/20100101 Firefox/53.0" > 2017-02-24 09:05:26,144 DEBUGHTTP response complete for > http.response!GAGdgGoUEFHo > 10.0.2.2:1048 - - [24/Feb/2017:

Re: Sometimes Channels does not work properly

2017-02-26 Thread Andrew Godwin
Don't worry about the redis traffic, that's normal. Instead, what would help is: * Knowing the versions you have of django, channels, Daphne, asgiref and asgi_redis * Seeing the console output from the server (and a worker if you are running one, but you don't if you are using runserver) * Getti

Re: Channels - slow with limited number of connections

2017-03-05 Thread Andrew Godwin
Python threads are not that great at sharing I/O - I'd recommend you run at most one or two per physical CPU core in your machine. 500 is just going to suffocate Python in context switching. We have loadtests that definitely got above 10 messages a second - what ASGI backend are you using? What si

Re: Channels - slow with limited number of connections

2017-03-05 Thread Andrew Godwin
If your channels get full it means your workers aren't draining the channels fast enough - you should spin up more workers. At some point you also need to increase the channel capacity as well to smooth out bumps, but the channel capacity only needs to be about the same as the number of requests pe

Re: Channels vs serverless: how much they are alike

2017-03-06 Thread Andrew Godwin
Channels' message queue is designed for a much lower latency than most "serverless" solutions, which are more often for non-interactive processing. There's a whole host of other differences too, around design, deployment, etc. that are all tradeoffs; at some point, a lot of distributed systems come

Re: Django Channels - Delay server for Group messages

2017-03-07 Thread Andrew Godwin
Not at the moment, the delay server is not built with that in mind. It could be extended to do so if you wanted to look into it. Andrew On Mon, Mar 6, 2017 at 2:09 PM, Adrián Cuesta wrote: > Hi > > Is there any way to send delayed messages to Group instead of a Channel? > > The delay server exa

Re: Channels + steam(gevent based package)

2017-03-07 Thread Andrew Godwin
Where are you running this steam client from? Presumably not a webserver process, as that doesn't have a main thread. Could you explain a bit more about the architecture and what channel layers you have configured? Andrew On Tue, Mar 7, 2017 at 4:06 AM, Lada B wrote: > I'm using > > https://git

Re: Channels + steam(gevent based package)

2017-03-07 Thread Andrew Godwin
nal function above. > Then mess I explained above starts to happen. > Even tho steam client is working properly, channels are not and daphne > crashes because of block forever errors and backpressure. > > > > > Dne úterý 7. března 2017 19:08:39 UTC+1 Andrew Godwin napsal(a): >

Re: Channels + steam(gevent based package)

2017-03-07 Thread Andrew Godwin
art new Process then its broken > and there i some fork error in the end. > > Dne úterý 7. března 2017 19:45:36 UTC+1 Andrew Godwin napsal(a): >> >> So you are starting a steam client from a consumer inside a worker >> process then? Inside a consumer, send() calls w

Re: Will asgi become a PEP like wsgi is ?

2017-03-12 Thread Andrew Godwin
I'll reply to this in the same subject thread on django-developers. Andrew On Sat, Mar 11, 2017 at 2:29 PM, Sebastian Haase wrote: > Hi, > > wsgi is specified by > PEP 333 -- Python Web Server Gateway Interface v1.0 > https://www.python.org/dev/peps/pep-0333/ > > Django channels rely on asgi in

Re: Django channels being used instead of celery.

2017-03-14 Thread Andrew Godwin
Hi, You could do this with channels - it also gets configured with a single central address (the Redis server, in this case) so it would be possible to run workers on each of the Pis and configure them to talk to the central Redis server. However, depending on how reliable you want your results t

Re: Attach consumer to dynamically created single-reader channel (Django Channels)

2017-03-19 Thread Andrew Godwin
Workers can't dynamically change their channels during runtime, but you can tell workers to only run specific channels in one of two ways: - Have different routing configurations and different settings files that point to each for the two worker groups - Use the --only-channels and --exclude-cha

Re: Django channels, more than one project

2017-03-24 Thread Andrew Godwin
Run two Daphne instances, each with a different channel layer configured. To make sure the channel layers for the apps do not conflict, configure them either with different Redis servers or different values for the "prefix" argument to the channel layer on the same server. Andrew On Fri, Mar 24,

Re: Channels - get online users

2017-03-25 Thread Andrew Godwin
Well, your problem is that you have to first define "online" and "users". If you want "the number of open WebSockets connected to the system", then you can do it using logic tied to the connect and disconnect methods, with extra logic for expiry in case you miss a disconnect (otherwise the number

Re: Channels - logout not resetting message.user value on new WebSocket connections

2017-03-26 Thread Andrew Godwin
This isn't a known issue, but I'll need more debugging info to know if it's Channels or not. Couple of checks: - The way to reject a socket connection is "close": True, not "accept": False; try changing to that - What is the value of message.user and message.reply_channel on each of a a) correct

Re: Channels - logout not resetting message.user value on new WebSocket connections

2017-03-27 Thread Andrew Godwin
6:37 AM, Melvyn Sopacua wrote: > On Sunday 26 March 2017 15:40:28 Andrew Godwin wrote: > > > > > - The way to reject a socket connection is "close": True, not > > > "accept": False; try changing to that > > > > If there is no use case for &#

Re: Channels - logout not resetting message.user value on new WebSocket connections

2017-03-27 Thread Andrew Godwin
To follow up on this - I have updated the spec ( http://channels.readthedocs.io/en/latest/asgi/www.html) to clarify exactly how accept works, added accept: False as an allowed value, and patched Daphne to work with that as of next release. Andrew On Mon, Mar 27, 2017 at 9:52 AM, Andrew Godwin

Re: Would it be a good idea to build a IM app using django channels?

2017-03-31 Thread Andrew Godwin
Hi Vic, Channels would be a suitable building block for such an app, certainly, but you'd need to do a lot more work on top of it. Online presence management, chat history, login, authentication, and the protocol would all be the things you need to solve - Channels just gives you a basic eventing

Re: channels/redis exception: TypeError: __init__() got an unexpected keyword argument 'socket_connect_timeout'

2017-04-04 Thread Andrew Godwin
Hi, This is https://github.com/django/asgi_redis/issues/36 - fix is already committed, should be releasing today. Andrew On Mon, Apr 3, 2017 at 3:41 PM, wrote: > Hi all ! > > TypeError is raised when asgi_redis tries to open a connection to redis: > > ``` > Traceback (most recent call last): >

Re: Django Channels - Class Based Consumers

2017-04-04 Thread Andrew Godwin
Hi Dan, An initial glance shows that you might be passing the arguments wrong to Multiplexer.group_send(group_name, stream, payload) - I'm not sure why you are using multiplexer.__class__.__name__ as the group name, but the group name you configured in connection_groups is updatedb_results, and th

Re: Django Channels - Class Based Consumers

2017-04-05 Thread Andrew Godwin
ction. > > Not fully understanding classmethods, I was trying to pass the cls > argument as well. > > I understand what the group_name and payload arguments do - but what s the > stream argument doing? > > Dan > > On Tuesday, 4 April 2017 13:57:07 UTC+1, Andrew Godwin w

Re: "'txredisapi' is not defined" after Update to Django 1.11 with Django Channels

2017-04-05 Thread Andrew Godwin
Hi, Can you make sure your asgi_redis installation is upgraded all the way too? And which exact version of Channels do you have installed? Andrew On Wed, Apr 5, 2017 at 4:07 PM, Jochen Breuer wrote: > Hi! > > After Updating Django to version 1.11 with a current Channels installation > based on

Re: Django channels 1.1.3 not found on pip

2017-04-06 Thread Andrew Godwin
This is now fixed. There was a problem with the release process. Andrew On Fri, Apr 7, 2017 at 4:19 AM, Vaisagh Viswanathan wrote: > I am using django-channels for my project and I needed the specific bug > fix that is part of 1.1.3 version. However, even though the release notes: > https://cha

Re: Channels Redis/channelfull spam without any ws connections.

2017-04-07 Thread Andrew Godwin
The first part is normal Redis traffic for Daphne. It polls Redis in a pretty tight loop in synchronous mode (and this is, annoyingly, faster than the slow poll in Twisted-native mode). The second part is an unrelated error that appears to be from handling a WebSocket that was incoming - is it rep

Re: Automatic reverse migrations

2017-04-14 Thread Andrew Godwin
Hi Paul, I have tried this in the past, but it's basically an unsolvable problem in the generic case. Databases do not take well to snapshotting or changing schema, and some operations are naturally irreversible. If you find a way that works well, I suggest you write it up so others can learn from

Re: Attach consumer to dynamically created single-reader channel (Django Channels)

2017-04-25 Thread Andrew Godwin
g, or Daphne simply does not implement > this concept and therefor cannot handle large requests sequentially by > chunking them? > > воскресенье, 19 марта 2017 г., 21:18:07 UTC+3 пользователь Andrew Godwin > написал: >> >> Workers can't dynamically change their channels dur

Re: Multiplex results from (Django-Channels)

2017-04-25 Thread Andrew Godwin
Hi - I'll only reply to this thread, as you seem to have posted it twice with different subjects. If you're going with the groups approach, as it seems you are, you need to add the user to multiple groups, one for each room, and then stick the room name in the group sends so you can distinguish th

Re: Multiplex results from (Django-Channels)

2017-04-26 Thread Andrew Godwin
When the connection comes in, you put them in a group based on the URL like this: Group('chat-' + label).add(message.reply_channel) Instead, if you want multiple rooms down one WebSocket, you need to add them to a group for all of the rooms that the connection should receive messages for. Either

Re: Multiplex results from (Django-Channels)

2017-04-26 Thread Andrew Godwin
I only have limited time for free advice, unfortunately, so I can't help you write everything! However, it looks like your problem is that you are trying to add to a group called: 'chat-' + listrooms Where listrooms is a queryset - that doesn't make any sense. You need a for loop instead. Andrew

Re: Channels, Websockets and 'Backpressure'

2017-04-27 Thread Andrew Godwin
tually scale it? > > Sorry for my ignorance, I'm very worried that the project is a failure in > start. It may never reach the expected numbers, but the system will appear > on the television network and we have chances that it will actually happen > (at least a few minutes) >

Re: Django Channels App Design

2017-04-28 Thread Andrew Godwin
Hi Ethan, Distributed collaboration is kind of a generally unsolved problem, so there's no real best approach for what you have here. Having each environment assigned to a single process (worker) definitely helps keep things in shape, and if it's working for you, then I'd keep going with it. My p

<    1   2   3   4   >