Re: Django Channels, Nginx, Daphne - Not working?

2017-05-02 Thread Andrew Godwin
Aha, it looks like your daphne instance is only listening on localhost: 2017-05-02 07:01:04,853 INFO Starting server attcp:port=8000:interface=127.0.0.1, channel layer firstproject.asgi:channel_layer. Try binding to all interfaces by passing -b 0.0.0.0 to Daphne when it starts. Andrew On

Re: Django Channels, Nginx, Daphne - Not working?

2017-05-03 Thread Andrew Godwin
Well, if daphne is serving you webpages, then the channel layer is working fine (everything goes over it, including HTTP). However, if you are just using Daphne for websockets, then it may not be working at all - which is the case? And are the worker and daphne processes running on the same machine

Re: [Channels] Recommended quantity of workers

2017-05-03 Thread Andrew Godwin
The number you need depends on the kind of site you have and the type of traffic - much like "how many WSGI servers should I run?" there is no right answer. You'll need to look at how different numbers of workers affect your median response times and number of timeouts and adjust appropriately. Th

Re: Daphne and Intermediate certificate

2017-05-04 Thread Andrew Godwin
You can - if you use the `-e` method of passing arguments to Daphne, as a couple of the examples in the README show, you can use the full Twisted endpoint syntax, which allows a extraCertChain parameter. You can see their documentation here, including example syntax for how that would look: https:

Re: CPU usage by workers

2017-05-08 Thread Andrew Godwin
Daphne does tend to idle hot, but this is so it performs better under high load. It's not clear from your description which of the processes is using more CPU as connections come through and then disconnect - is it Daphne or is it runworker? Andrew On Mon, May 8, 2017 at 5:46 AM, qnub wrote: >

Re: Channels - using SSL with reverse proxy behind Apache. Does Daphne need to support SSL and WSS?

2017-05-08 Thread Andrew Godwin
Hi, First, to proxy WebSockets, you have to use mod_proxy_wstunnel - the build-in mod_proxy does not understand the headers that allow WebSocket upgrades and will generally make it fail. Once you have that, you do not need to configure Daphne to terminate SSL because Apache is doing it for you -

Re: Django Channels: Multiple 'send' calls in the same consumer

2017-05-13 Thread Andrew Godwin
Hi Tristan, All messages sent from a consumer are delayed for sending until the consumer exits to keep things atomic - long-running consumers is bad for performance, as they'll hog an entire thread (they run synchronously) and so you'll quickly run out of threads/processes as you'll end up using o

Re: Channels - unbalanced load for threaded workers

2017-05-17 Thread Andrew Godwin
Hi - I am not sure what you are saying exactly. That the load only goes to some processes? Python threads are strange, the OS may not show stats correctly and I'd generally advise multiple processes instead. Andrew On Wed, May 17, 2017 at 1:53 AM, wrote: > I am trying to deploy Django project w

Re: Channels - unbalanced load for threaded workers

2017-05-18 Thread Andrew Godwin
; > W dniu czwartek, 18 maja 2017 02:18:56 UTC+2 użytkownik Andrew Godwin > napisał: >> >> Hi - I am not sure what you are saying exactly. That the load only goes >> to some processes? Python threads are strange, the OS may not show stats >> correctly and I'd gene

Re: Send endpoint commands through runserver

2017-05-26 Thread Andrew Godwin
I've already answered the issue you opened on this topic: https://github.com/django/channels/issues/646 Andrew On Fri, May 26, 2017 at 12:37 PM, U.G. Wilson wrote: > Is it possible to send endpoint commands through runserver? > > In daphne I can do this: > > daphne -v2 -e ssl:443:privateKey=key

Re: Django Channels and Background Processes

2017-05-30 Thread Andrew Godwin
Hi Markus, There is no plan to roll Channels up to and including the 2.0 release so far - it's persisting as an external project for now with its own release cycle. Some of what you describe can be done with Channels - it gives you an inter-process messaging framework for sending data between pro

Re: Pyinotify and runserver performance with django channels in docker for mac

2017-06-01 Thread Andrew Godwin
Can I ask what channel layer you are using? That's what affects the speed of messages being transported. Andrew On Thu, Jun 1, 2017 at 1:36 AM, qnub wrote: > Not sure what exactly wrog here, but installing pyinotify not helps to > lower CPU usage in docker on mac OS. As i understand after googl

Re: Pyinotify and runserver performance with django channels in docker for mac

2017-06-01 Thread Andrew Godwin
v environment with single node but with `rundelay` we > use `asgi_ipc.IPCChannelLayer` > > On Thursday, June 1, 2017 at 11:03:09 PM UTC+6, Andrew Godwin wrote: >> >> Can I ask what channel layer you are using? That's what affects the speed >> of messages being transported.

Re: django channels group subscriptions

2017-06-01 Thread Andrew Godwin
You can't do what you ask with the current Groups system - it is deliberately very simple as anything more complex involves picking scaling tradeoffs that are particular to the thing it's powering. You'll have to layer some of your own code on top of groups (you can keep groups for the broadcast me

Re: django channels group subscriptions

2017-06-01 Thread Andrew Godwin
ld something on. Andrew On Thu, Jun 1, 2017 at 8:58 PM, Brian May wrote: > On Friday, 2 June 2017 13:04:48 UTC+10, Andrew Godwin wrote: >> >> You can't do what you ask with the current Groups system - it is >> deliberately very simple as anything more complex invol

Re: django channels group subscriptions

2017-06-01 Thread Andrew Godwin
shut it down early) Andrew On Thu, Jun 1, 2017 at 9:26 PM, Brian May wrote: > On Friday, 2 June 2017 14:08:40 UTC+10, Andrew Godwin wrote: >> >> I don't have any direct examples to hand - and this sort of thing does >> come all the time, but much like Django is not in

Re: Channel- Can I dynamically adjust the amount of workers?

2017-06-03 Thread Andrew Godwin
Hi Dennis, You can scale the number of workers using something designed for that sort of auto-scaling - you just need an image that runs a worker and something that knows how to launch and stop those images on whatever platform you're using (AWS, Google Cloud, Kubernetes, Docker, Nomad, etc.). It'

Re: django-channels with django-tenant-schemas

2017-06-05 Thread Andrew Godwin
Does the WebSocket handshake finish? The developer console in a browser should tell you if it actually opens up or not. Normal Django middleware shouldn't affect WebSockets as it's a different networking style, but it's very easy to get WebSockets set up wrong for a variety of other reasons. Andr

Re: Channels : disconnect alone

2017-06-06 Thread Andrew Godwin
Are you accepting the connection in a consumer on `websocket.connect`? Is there some proxy in the way that's dropping WebSocket packets, meaning the ping times out and Daphne closes it? There's a lot of reasons why a websocket can close after a timeout, and most of them are related to your setup a

Re: Pyinotify and runserver performance with django channels in docker for mac

2017-06-14 Thread Andrew Godwin
nd looks like it helps (hope it works > faster not because of my hardware upgrade but because of Reis usage). So > with redis page loads in 10 seconds instead of 1,5 minutes with IPC. > > On Thursday, June 1, 2017 at 11:33:28 PM UTC+6, Andrew Godwin wrote: >> >> OK, can you try

Re: Django Channels : High CPU usage by workers and 503 responses.

2017-06-15 Thread Andrew Godwin
The error you have looks like https://github.com/django/channels/issues/643, which was fixed in the master branch but not released yet. Could you install channels from the master git branch and see if that improves things? Andrew On Thu, Jun 15, 2017 at 7:19 PM, RAUSHAN RAJ wrote: > Hi, > I am

Re: Send message to group from server on production by channels.

2017-06-15 Thread Andrew Godwin
What is your CHANNEL_LAYERS configuration? It sounds like the thing running the cron is not on the same layer as everything else. Andrew On Thu, Jun 15, 2017 at 11:27 AM, Петр Гордеев wrote: > Hi, > I have a problem with send message from backend on production. > If I want to send message to gr

Re: [django-channels] Issues with model post_save and Group.Send()

2017-06-19 Thread Andrew Godwin
What's the traceback when the code exits? There has to be some reason it stops there, and whatever your Python code is running in should be able to tell you why (traceback, status code, anything) Without that, I can't help, as it could be anything - your code or Django's. Andrew On Mon, Jun 19,

Re: [django-channels] Issues with model post_save and Group.Send()

2017-06-20 Thread Andrew Godwin
runs. After the > channels message, the request is stale, and just freezes the server. > > > On Monday, 19 June 2017 16:33:16 UTC+2, Andrew Godwin wrote: >> >> What's the traceback when the code exits? There has to be some reason it >> stops there, and what

Re: Websocket, an existing connection was forcibly closed by the remote host. django-channels

2017-06-27 Thread Andrew Godwin
I would need to see the full console output of the server, and a full package version listing of what you have installed to help you further. On Sun, Jun 25, 2017 at 12:48 PM, Mike Johnson Jr wrote: > So I'm getting the error as described in the title of this post. > > I'm following this tutoria

Re: Django channels for single user

2017-07-05 Thread Andrew Godwin
Yes, you should create a group per user. That way users with more than one tab open will get data sent to all tabs too. Andrew On Wed, Jul 5, 2017 at 6:42 AM, yingi keme wrote: > How will you create a web socket for a single user such that another > program can send a json data to thesame speci

Re: Channels: Sudden & Mysterious 400 Bad Request

2017-07-09 Thread Andrew Godwin
I don't really know what's going wrong then, I guess - 400 Bad Request is not something you'd get from misconfiguration usually. Do you get it from Nginx serving a static file too, or just when it proxies through? Andrew On Fri, Jul 7, 2017 at 7:55 PM, wrote: > I'm using Nginx -> Daphne -> Redi

Re: Django Channels compatibility with Google App/Compute Engine?

2017-07-09 Thread Andrew Godwin
Hi Alex, I don't have any specific advice for GCE - I'm not really sure what their special requirements are. You'll probably have to experiment and see if it's possible with what they supply. Andrew On Sat, Jul 8, 2017 at 1:47 AM, Alex Z wrote: > Hello! I'm really new here, and also relatively

Re: Django Channels - polling in consumer

2017-07-23 Thread Andrew Godwin
Hi John, You are right that trying to do polling inside a consumer will tie up a worker thread, and so it's not the right way to write this. Even more, we deliberately have Channels buffer outgoing messages until the end of the consumer, so you wouldn't see anything as it was polling. There's a m

Re: [Django Channels] Can I use the same redis server as message backend and cache backend the same time?

2017-08-05 Thread Andrew Godwin
1. You can - Channels namespaces itself away from most keys you might use (and you add a custom prefix with the "prefix" option). 2. Yes, as long as both sites have a different prefix setting In both cases I would recommend using separate Redis servers though. They have very low RAM usage and it'

Re: Django Channels and multiple servers

2017-08-06 Thread Andrew Godwin
You probably got into a moderation queue. I'll reply to the other post. Andrew On Mon, Aug 7, 2017 at 4:49 AM, Cristiano Coelho wrote: > For some reason my original question got lost. > > http://channels.readthedocs.io/en/stable/deploying.html > > I don't quite understand this part: > > The fun

Re: About channels and scaling up

2017-08-06 Thread Andrew Godwin
Yes, this is a problem, and as it says it would only work for some site designs (where you're OK with sharding the live userbase). We're fixing this architectural issue in the next major Channels release, but it's going to take a little time. Andrew On Mon, Aug 7, 2017 at 4:21 AM, Cristiano Coelh

Re: Django Channels - Throttling/Traffic Management?

2017-08-08 Thread Andrew Godwin
Hi Jamie, At the moment Channels has quite limited support for throttling - it pretty much consists of an adjustable channel size for incoming connections which, when full, will cause the server to return a 503 error. Workers are load-balanced based on availability due to the channels design, so t

Re: Django Channels - Throttling/Traffic Management?

2017-08-10 Thread Andrew Godwin
gt; rewrite? I'm working on a project right now that I'm hoping will see the > light of day in production, but would hate to get version-locked if the > rewrite changes too much. > > Thank you! And keep up the great work. > > Jamie > > On Tuesday, 8 August 201

Re: Channels: Add channel from one group to another

2017-08-20 Thread Andrew Godwin
There's no fast-performing way to do this - we'll be able to make it easier in the upcoming Channels 2.0, but for now the best you could get is going through the list of channels in the group and that's very slow. Andrew On Sat, Aug 19, 2017 at 11:33 PM, Никита Екатеринчук wrote: > I have an ap

Re: Need help: webrtc signalling with django app

2017-08-23 Thread Andrew Godwin
My impression was that RTC signalling was not specified or defined so apps could do it how they wish - so you could use normal AJAX, or WebSockets, etc. Channels doesn't have RTC support as, as far as I could tell, the specified parts are all browser-to-browser. Andrew On Wed, Aug 23, 2017 at 7:1

Re: Setting up a "update" async with channels

2017-08-28 Thread Andrew Godwin
You also asked this as a GitHub issue with more detail ( https://github.com/django/channels/issues/728) - I'm going to close that and answer it here, since this is the right place. I don't have a good example for this, but I will outline how I would roughly do it (which your code already sort of d

Re: [Channels] Worker Live Reload

2017-08-29 Thread Andrew Godwin
There is no live reload on runworker at the moment - this problem will be mostly fixed with Channels 2.0, though, when we eliminate the need for runworker. Until then, it's not an easy thing to add, but if you're feeling ambitious, it's the sort of thing I would happily take a patch for. Andrew

Re: get json sent to channels in view

2017-08-30 Thread Andrew Godwin
You want to look for incoming data on the "websocket.receive" channel, which will call you once per message you send down with the right data. That's "websocket.connect", which happens after the socket opens but before data is sent down it. Andrew On Wed, Aug 30, 2017 at 10:07 AM, Samuel Muiruri

Re: Channels - Forward messages from a third party async source.

2017-09-01 Thread Andrew Godwin
Hey, You can send onto Channels from anywhere, event loop or no, but if you want a background process that monitors an external source and forwards events from it you will need to write that yourself (I usually suggest management commands for this purpose). I'm working on hopefully making it easi

Re: Processing data sent by sockets in django-channels

2017-09-04 Thread Andrew Godwin
Hi, I don't keep track of stack overflow so I don't know if anybody else would answer stuff there. Secondly, I replied to a very similar question you asked on this list last week - is this the same problem as that? Andrew On Mon, Sep 4, 2017 at 1:45 AM, Samuel Muiruri wrote: > According to dj

Re: Django channels

2017-09-07 Thread Andrew Godwin
Yes, you'd need to do this manually - the databinding in Channels right now is very barebones and doesn't handle initial state versus change management. I'd love to eventually get a full event-sourcing solution done, but I have a lot of things I would like to do! Andrew On Thu, Sep 7, 2017 at 7:3

Re: Django channels

2017-09-08 Thread Andrew Godwin
Not yet - feel free to file one and tag/label it as a feature request, but it's unlikely to be done soon as there's a lot of foundational work to be done at the moment :) Andrew On Fri, Sep 8, 2017 at 3:21 AM, wrote: > Thanks a lot. Is there any Github issue? Maybe if I have time in a future, >

Re: How to authenticate a user in websocket connection in django channels when using token authentication

2017-09-15 Thread Andrew Godwin
You'll have to write your own authentication code that runs in `connect` and puts a user into the channel session - there's nothing built in that will really help you past that I'm afraid. Andrew On Thu, Sep 14, 2017 at 6:35 PM, Robin Lery wrote: > I am using a frontend framework (Vuejs

Re: Channels architecture for chat application and subscriptions

2017-09-17 Thread Andrew Godwin
Hi Robin, The most efficient way to do this is to have one WebSocket connection that all the messages are sent down. Have a Group per group-chat and per single-user chat (I would model those as a special case of the group-chat if I were you for simplicity), and when a user connects, add them to th

Re: Channels architecture for chat application and subscriptions

2017-09-20 Thread Andrew Godwin
.all(): > Group("%d" % user.id).send({ > "text": json.dumps({ > "foo": 'bar' > }) > }) > > > Also to consider here is that suppose a thread has a large number of users > (say, more than 20,000 users), wi

Re: ASGI alongside mod_wsgi behind an Nginx proxy

2017-09-23 Thread Andrew Godwin
Hi there, This is a current bug with the root path setting - see https://github.com/django/daphne/issues/125. Until it's fixed, I'd recommend just coding all URLs as absolute and making nginx pass them through as such. Andrew On Fri, Sep 22, 2017 at 2:13 PM, Sean F wrote: > Hi all, > > I'm try

Re: Channels: Using `allowed_hosts_only` with `WebsocketDemultiplexer`

2017-09-25 Thread Andrew Godwin
It's pretty tough right now to use the decorators with the classes (this is why things like http_user are built-in) - you have to wrap them around the handle method, if I remember correctly. I'm hoping to fix this with the design of Channels 2 by changing the way classes get called, but that's not

Re: Django Channels: best way to launch multiple workers

2017-10-10 Thread Andrew Godwin
t; return cpu_count() * 2 + 1 > > > > > On Thursday, February 9, 2017 at 11:38:07 AM UTC+13, Andrew Godwin wrote: >> >> The difference is mostly in Python performance - threading in Python >> tends to perform worse than using multiple processes, which is why we &g

Re: Django Channels: Comparison to ipyparallel

2017-10-12 Thread Andrew Godwin
I can't really comment exhaustively without using the other solution, but in my experience ZeroMQ is good at delivering results under working conditions (especially loopback networks as this seems to be) and bad at failure under poor conditions. Besides, Channels is more for handling of event stre

Re: Django Websockets / Several Users on the Website

2017-10-12 Thread Andrew Godwin
On Wed, Oct 11, 2017 at 3:02 AM, 'matrix1900' via Django users < django-users@googlegroups.com> wrote: > Hi together, > > I try to get started with Django Channels. I have actually two questions: > > 1. I use web sockets with channels. I want to have for each frontend user > which opens the websi

Re: Redirect Loops and 404 with Django Channels and runserver command

2018-06-09 Thread Andrew Godwin
Hi Justin, I'm going to reply to you on the ticket you opened at https://github.com/django/channels/issues/1075 with the same question :) Andrew On Fri, Jun 8, 2018 at 7:56 AM Justin Lee wrote: > I was just trying to integrate channels into an existing django/DRF > project and I have been runn

Re: Chatbot using Django Channels. Persist a python object in a scope?

2018-06-10 Thread Andrew Godwin
Hi! You can indeed have things persist for the entire scope - the Consumer (or any other ASGI app) does exactly this, and so if you're in a consumer you can just store things on "self". That'll be tied to a specific socket and garbage-collected once it's done (on Channels 2 only - channels 1 didn'

Re: Django Channels 2.0 websocket crashing & blocking while using aiohttp

2018-06-17 Thread Andrew Godwin
I'm not quite sure why you seem to be using an AsyncConsumer outside of the context of the Channels routing framework? Anyway, it sounds like from what you're describing that your listen() method is blocking, which makes sense, as it connects to an external websocket and listens on it for messages

Re: Django Channels 2.0 - How to init and persist/communicate with only one instance of background worker for every channel_layer.send?

2018-06-21 Thread Andrew Godwin
The worker server tries to keep one application instance open per incoming channel name, but that's no guarantee. It will always make a new instance for different channel names. What kind of behaviour are you expecting? Andrew On Tue, Jun 19, 2018 at 6:45 AM itsnate_b wrote: > I am using Django

Re: Django Channels 2.0 - How to init and persist/communicate with only one instance of background worker for every channel_layer.send?

2018-06-23 Thread Andrew Godwin
g one channel name and my expectation is that only one > instance of the background worker class should be initiated/used. Instead, > I am seeing a new class being initiated for each call routed to the > background worker class. This is unexpected... > > > On Thursday, June 21, 201

Re: Channels 2.0 close code and http response status

2018-06-23 Thread Andrew Godwin
Hi! Close code 1006 means that the connection was closed abruptly by the other end (basically, the socket just got chopped off without an actual close frame being sent). This is what happens when you close during the handshake, which is what closing during connect() does - at that point, the conn

Re: Channels 2.0 close code and http response status

2018-06-24 Thread Andrew Godwin
I'm not quite sure - WebSockets do have browser differences. You could also try adding a delay between the accept and the close to see if that changes how they handle it. Andrew On Sun, 24 Jun 2018, 06:02 Kirill Tyushchakov, wrote: > Hi, Andrew! Thanks a lot for your response. > I've changed my

Re: Channels 2.0, How can I configure the channels 2.0 to use with the default django's views

2018-06-24 Thread Andrew Godwin
I'm not quite sure what you mean - Channels will still serve Django views as well unless you override HTTP serving as well as WebSocket, and even then, you can follow the URLRouter docs to keep it working fine: http://channels.readthedocs.io/en/latest/topics/routing.html#urlrouter Andrew On Thu,

Re: How to handle Video/Audio streaming using Django Channels?

2018-06-25 Thread Andrew Godwin
ote: > Hi Andrew - With Channels 2, can we have real-time audio/video streaming? > Thanks/Tirthankar. > > On Saturday, November 5, 2016 at 4:16:21 AM UTC+5:30, Andrew Godwin wrote: >> >> Hi Sandro, >> >> Real-time video streaming is pretty intensive, and WebRTC al

Re: ERROR - server - Error trying to receive messages: name 'txredisapi' is not defined

2018-07-13 Thread Andrew Godwin
What version of Channels are you using? It looks like you're trying to use Channels 1 without Twisted redis support installed - did you try installing the package it's asking for? Andrew On Thu, Jul 12, 2018 at 4:22 AM Hank Chu wrote: > 2018-07-12 17:35:08,070 - INFO - worker - Listening on cha

Re: [django-channels client wrapper] specifying no reconnection attempts

2018-07-15 Thread Andrew Godwin
I don't know much about that JavaScript code, I'm afraid, otherwise I would try and help (it's likely we're going to deprecate support for it soon as there's no maintainer for it right now anyway). Take a look through the source code and see if there's something you can call to stop reconnection a

Re: Django Channels: long running async function and where to save ORM object

2018-07-16 Thread Andrew Godwin
You are correct in that you could store the model instance on "self" but this would result in caching issues, as that instance would not be updated after the initial socket connection. If you want to run "background routines", I would discourage you from doing these as random orphaned tasks launch

Re: Django Channels: long running async function and where to save ORM object

2018-07-18 Thread Andrew Godwin
se async code inside that worker > process ? > While developing I simply do arun_serveron the command line -- > then I would always have to do arun_worker in addition -- right ? > > -Sebastian > > > On Mon, Jul 16, 2018 at 7:05 PM, Andrew Godwin > wrote: >

Re: [Channels] How to write tests with database access?

2018-07-22 Thread Andrew Godwin
Asynchronous testing is very hard, unfortunately. I suspect what you are doing is awaiting the sending of the message, but not awaiting any response back, so your test continues once it's sent the message into the application but not waiting for that application to finish processing. The best patt

Re: How to check if server is running in ASGI or in WSGI mode?

2018-07-22 Thread Andrew Godwin
Where do you want to detect this? There's no official way of knowing, because you're meant to detect based on features/what gets called. Andrew On Thu, Jul 19, 2018 at 2:12 PM Rafis Ganeev wrote: > We are running same django project in WSGI mode for handling HTTP requests > and in ASGI mode for

Re: Channels/Redis fault tolerance with Twemproxy?

2018-07-22 Thread Andrew Godwin
I'm afraid I've never used Twemproxy, so I can't really comment on it, but if you don't care about data loss, it's probably fine? Andrew On Fri, Jul 20, 2018 at 3:30 PM Filbert wrote: > Going to have 10 or more EC2 instances running Channels 2.0. I really > don't want to add the complexity of

Re: Channels/Redis fault tolerance with Twemproxy?

2018-07-22 Thread Andrew Godwin
lerance, correct? > > On Sunday, July 22, 2018 at 12:57:22 PM UTC-4, Andrew Godwin wrote: >> >> I'm afraid I've never used Twemproxy, so I can't really comment on it, >> but if you don't care about data loss, it's probably fine? >> >> Andrew

Re: Connecting to remote host like Twitch to monitor chat using websockets

2018-07-24 Thread Andrew Godwin
Hi Dave, It depends on what the protocol for the chat room is, but Channels is more for hosting websocket-based applications than consuming them. I suspect you would be better off looking at websocket client libraries, if the chat socket is even accessible. Andrew On Mon, Jul 23, 2018 at 4:45 PM

Re: User Authenticated in Gunicorn and Daphne

2018-07-27 Thread Andrew Godwin
You can configure Nginx to route to different backends based on path - put your Nginx proxy_pass settings inside a "location" block. You can find examples on Stack Overflow - for example: https://stackoverflow.com/questions/13399252/nginx-reverse-proxy-to-multiple-backends Andrew On Tue, Jul 24,

Re: Problem with sending django channels event from models

2018-07-27 Thread Andrew Godwin
You need to post the full traceback, not just the last section. I suspect what you are doing is calling model methods directly in an async function, but I can't confirm that without a full traceback. Andrew On Thu, Jul 26, 2018 at 1:10 PM luan fonceca wrote: > Hello, i'm trying to implement a "

Re: Problem with sending django channels event from models

2018-07-31 Thread Andrew Godwin
cba067d4caa8bfcf22d683409531#file-test-py> > . > > https://gist.github.com/luanfonceca/dafecba067d4caa8bfcf22d683409531 > > > Thanks for everything, Andrew. > > Em sex, 27 de jul de 2018 às 19:30, Andrew Godwin > escreveu: > >> You need to post the full traceba

Re: Channels/Redis fault tolerance with Twemproxy?

2018-08-02 Thread Andrew Godwin
ay) three of them crash, will Channels continue to try and hash to the >> dead servers? Again, I'll accept a brief set of errors, but if this >> effectively causes Channels to continue to error that is not my definition >> of HA. >> Thanks. >> >> On Sunday, Ju

Re: Channels/Redis fault tolerance with Twemproxy?

2018-08-02 Thread Andrew Godwin
x27;t > need some form of HA. Buried trying to get a product out the door right > now, but as I get time and more familiar with channels I'll probably dig in > deeper on this. > Thanks. > > On Thursday, August 2, 2018 at 7:32:52 PM UTC-4, Andrew Godwin wrote: >> >&

Re: Channels/Redis fault tolerance with Twemproxy?

2018-08-05 Thread Andrew Godwin
x27;t write against a read only slave. > > > Which I assume means Daphne doesn't detect a problem and just keeps the > socket open on the (old) master that is now the slave. > > > On Thursday, August 2, 2018 at 8:53:24 PM UTC-4, Andrew Godwin wrote: >> >>

Re: Channels thread count is increasing

2018-09-17 Thread Andrew Godwin
There's a reasonably large threadpool that sync_to_async uses (I think it defaults to number of CPU cores * 5), so you're probably just seeing that. It should stop growing at some point. Andrew On Sat, Sep 15, 2018 at 4:02 PM erkin kabataş wrote: > Hi All, > > I am new to python and django. > I

Re: django ORM with asyncio

2018-09-18 Thread Andrew Godwin
The Django ORM can't just be used with asyncio directly, sadly. The database_sync_to_async function you found there will help you call the ORM from asynchronous code, but it still runs the ORM in a synchronous thread (see https://channels.readthedocs.io/en/latest/topics/databases.html) The project

Re: Deploying Django app with Channels on Linux Hosting

2018-10-03 Thread Andrew Godwin
Hi there - it sounds like your host does not support websockets. You should check with them for more. Andrew On Wed, 3 Oct 2018 at 23:43, Manjunath wrote: > Hi all, > I have developed a simple app using django channels. > > I would like to deploy it on a linux hosting provider (Currently I have

Re: Channels: rejecting web socket connections with a custom close code

2018-10-06 Thread Andrew Godwin
Hi Matt, This is because the two ways of closing are different - closing before the socket is open sends a HTTP error code (what browsers report for this is different in terms of websocket errors), whereas closing once it is open allows a websocket error to be used. This is referenced in the spec

Re: [channels] 2.1.4 - Removing Javascript library entirely

2018-10-21 Thread Andrew Godwin
That's about right - you should ship and maintain the file yourself now. Andrew On Sun, 21 Oct 2018, 09:04 kradem, wrote: > Hi everyone! > > The subject is related to > https://github.com/django/channels/commit/2a9d764ad03927581aa2bfcadccc3e953949cb98 > > > It was very unmaintained, and having

Re: Channels: about max message size

2018-10-23 Thread Andrew Godwin
Hmm, it's possible the 0.x series didn't have response streaming for files so there'd be a limit, but I honestly can't remember, that was years ago. There's really not much I can do other than recommending an upgrade to something vaguely recent. Also make sure Heroku is not cutting you off with a

Re: Channels -- a question about how ProtocolTypeRouter works

2018-10-26 Thread Andrew Godwin
Hi Drew, The return value is indeed an object, but if you look closely at it you'll see it defines a __call__ method - meaning that when it's called as an ASGI application, it then returns a further object to act inside the scope. Andrew On Fri, Oct 26, 2018 at 2:55 PM Zhiyu/Drew Li wrote: > H

Re: Channels -- a question about how ProtocolTypeRouter works

2018-10-26 Thread Andrew Godwin
i application -- a obj just lasts for one scope. > I need to go through the code deeper. > > Thanks > Drew > > > > On Fri, Oct 26, 2018 at 4:07 PM Andrew Godwin wrote: > >> Hi Drew, >> >> The return value is indeed an object, but if you look closely at it

Re: How to subclass AsyncHttpConsumer for a GET request?

2018-10-29 Thread Andrew Godwin
Yup, that's the right way - subclass the async consumer class and then write a handle method. You have to do your own post/get distinctions, like in a Django view, but with the scope rather than the request. Andrew On Mon, Oct 29, 2018 at 4:37 PM Zhiyu/Drew Li wrote: > Not sure if this is the b

Re: How to subclass AsyncHttpConsumer for a GET request?

2018-10-30 Thread Andrew Godwin
put 'http': > MyAsyncHttpConsumer pair in the ProtocolRouter, all existing sync http > views stopped running as their type is "http" as well. So how to do a mix > of async HTTP and sync http? > Thanks > Drew > > On Mon, Oct 29, 2018, 23:15 Andrew Godwin wrot

Re: Adding Channels to and Existing Django Application

2018-11-05 Thread Andrew Godwin
Hey, You can just add channels to an existing Django project and only use it for the bits you need it for - even down to running two different servers for that project, one normal WSGI one and one ASGI one to let you do async things. You shouldn't migrate any existing code to channels - just add

Re: Channels: event loop and thread

2018-11-06 Thread Andrew Godwin
Your assumptions are correct. The only extra thing to be aware of is that some Django interactions (like the Channels Auth middleware) need to do database connections and thus have to launch into a subthread for that, but that's also managed. Andrew On Tue, Nov 6, 2018 at 4:41 AM Zhiyu (Drew) Li

Re: Adding Channels to and Existing Django Application

2018-11-06 Thread Andrew Godwin
he config files could help me set > this up. > > Juarez > > On Monday, November 5, 2018 at 9:24:39 PM UTC-2, Andrew Godwin wrote: >> >> Hey, >> >> You can just add channels to an existing Django project and only use it >> for the bits you need it for -

Re: Channel: Migrate regular Django project to Channels2

2018-11-07 Thread Andrew Godwin
Channels doesn't take over at all unless you configure an async consumer. To make sure it's working I'd recommend writing a single async consumer, and running a test against that to ensure it works. Andrew On Wed, Nov 7, 2018 at 1:11 PM Zhiyu (Drew) Li wrote: > Hi there, > > I am trying to migr

Re: Django channels worker loses some messages

2018-11-11 Thread Andrew Godwin
Are you using Channels 1 or Channels 2? And which channel layer are you using? Andrew On Sun, Nov 11, 2018 at 5:05 AM Parsa Banihashemi < parsa.banihash...@gmail.com> wrote: > Hi, > I have a simple sync consumer which receives websocket messages from the > client, and each time, It passes a mess

Re: Channels: Test case fails on async.sleep(X>0)

2018-11-13 Thread Andrew Godwin
Couple of points: - Did you install pytest-django? That should help the settings thing. - There's a default 1-second timeout on get_response; pass timeout=4 to it and you should see that error go away. We have a default timeout because otherwise we can't tell if an async app has died/crashed and

Re: Channels group_send hangs in extrenal process

2018-11-13 Thread Andrew Godwin
I've never tried using the async-to-sync stuff with multiprocessing - first, I'd try removing that and see if it still works (just run from a management command or script directly). If it still fails, I'd suggest running a redis MONITOR to see if any traffic makes it to Redis at all. Andrew On T

Re: Channels + django-tenants

2018-11-13 Thread Andrew Godwin
What sort of hook would you be imagining? The DB connection stuff is deep inside Django itself, rather than in Channels, so I'm not sure what sensible top-level thing we could provide that would make sense. Andrew On Tue, Nov 13, 2018 at 2:16 PM wrote: > Django-tenants is a package to provide m

Re: Channels + django-tenants

2018-11-14 Thread Andrew Godwin
Hm, that's not sufficiently better than just supplying a new middleware to be honest. The sort of hooks I prefer are where you can subclass and improve what we ship with and give the user a new, non-fragile one, whereas that just sounds like it's injecting a function in. Honestly, given Channels i

Re: Django with Channels 2.1.1 Error During WebSocket handshake 404

2018-11-16 Thread Andrew Godwin
You cannot use gunicorn to run WebSockets or other async code - you need an ASGI server, like Daphne or uvicorn. Switch to one of those and it should start working. Andrew On Fri, Nov 16, 2018 at 8:11 PM Robert Fox wrote: > I am working on a project using Django and Channels 2.1.1. Everything i

Re: Channels: development issue with multiple daphne workers

2018-11-27 Thread Andrew Godwin
I'm not sure why you're getting the _UnixSelectorEventLoop - that sounds like a Twisted error you should search around for, and make sure you have the right package versions. --fd 0 should not be needed in that command line, since you're already passing the UNIX socket, I don't remember why it's

Re: Error of channels

2018-12-17 Thread Andrew Godwin
I've seen a lot of people have a similar error but I'm never sure what causes it - that said, I generally advise them to check their Redis logs to see if Redis is OK, as that could cause this? Andrew On Mon, Dec 17, 2018 at 11:36 AM wrote: > I had an error while build a chatroom useing django-c

Re: Error when installing channels

2018-12-24 Thread Andrew Godwin
This is a general problem with installing compiled Python packages on Windows. You'll need to install the compiler as outlined here: https://wiki.python.org/moin/WindowsCompilers (or search for "python visual c++ 14") Andrew On Sat, Dec 22, 2018 at 11:23 AM shiva kumar wrote: > Hai guys, I am g

Re: Django channels communication not asynchronous

2018-12-24 Thread Andrew Godwin
You appear to have missed an "await" before "self.send" - could that be the cause? In general, the best thing to do if things seem to "block" is to set the environment variable PYTHONASYNCIODEBUG=1 and Python will warn you if anything blocks for too long and seems synchronous. Andrew On Mon, Dec

Re: Django channels communication not asynchronous

2018-12-28 Thread Andrew Godwin
equire two websocket connections? One for requesting and another for > receiving responses Or am I going about it the wrong way > > On Monday, December 24, 2018 at 8:36:24 PM UTC+5:30, Andrew Godwin wrote: >> >> You appear to have missed an "await" before "s

<    1   2   3   4   >