Getting Django Channels working with NewRelic

2023-11-17 Thread Tim Nelson
I am trying to get NewRelic monitoring my ASGI code written in Django
Channels.

Most notably, this line of code from their examples should create a
NewRelic transaction and start monitoring all async activity.

   channel_layer =
newrelic.agent.ASGIApplicationWrapper(get_default_application())

Has anyone got this working?

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK09zooJF4dr9sVW2Fo71%3DQ%2Bf8Ahw38FxpZyhC%2BBPFTXPtGk9A%40mail.gmail.com.


Channels SyncConsumers locking up Uvicorn/Websockets

2023-06-19 Thread Tim Nelson
We have had the occasional case where it appears a given SyncConsumer
hangs. These seem to starve Channels of ASGI threads, eventually breaking
all clients that are trying to send or connect.

Is there any way to build in a timeout, meaning if a SyncConsumer doesn't
finish its request in (say) 5 seconds to interrupt it?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK09zoo3%2B0yjFiappMDEtZk99PNAO6aU7mUO9zVhSaNVondYEw%40mail.gmail.com.


Hanging SyncConsumers taking down ASGI processing

2023-04-28 Thread Tim Nelson
I am chasing a database deadlock issue in my application. What appears to
be happening is my SyncConsumers are eating up all the ASGI threads because
they are hung and websocket connections start failing.

Is there a way to add a uWSGI "harakiri" like functionality to
SyncConsumers to defend against this issue?

Django==3.2.5
channels==3.0.5
channels-redis==3.3.0
asgiref==3.5.2
uvicorn==0.15.0

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK09zopAv42Be3Dt6kk7_BV0_U4AtZh3gRnzmAcaQqms9FF7_A%40mail.gmail.com.


Multi-tenant SSO that supports OpenID and MS Azure AD

2022-11-07 Thread Tim Nelson
I am looking for a Django SSO package that supports OpenId and Azure AD
with multi-tenant support. My sense is I am going to have to roll my own by
forking the best of breed SSO's and adding multi-tenant support to them.

Is my assessment correct?
Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK09zooyoOOKO7Dyp5LAbqWDphLwfQLBKX2rRWhXZHPqNNjEtQ%40mail.gmail.com.


Re: Channels/Daphne offloading SSL Certs to AWS ELB fails to establish socket

2020-04-20 Thread Tim Nelson
Well if you want the clients IP logged or need to do something with it on
the request:

   set_real_ip_from 0.0.0.0/0;
   real_ip_header X-Forwarded-For;
   real_ip_recursive on;


On Mon, Apr 20, 2020 at 5:55 PM Shaheed Haque 
wrote:

>
>
> On Mon, 20 Apr 2020 at 21:54, Filbert  wrote:
>
>> *Answering my own question.AWS classic ELBs never worked properly
>> with websockets. Need to convert them to ALBs.*
>>
>
> Thanks for closing the loop; this is quite likely to be in my future. Did
> you need any nginx config changes?
>
> Shaheed
>
> On Tuesday, April 14, 2020 at 5:37:54 PM UTC-4, Filbert wrote:
>>>
>>> Using AWS ELB, I was able to serve HTTP (via uwsgi) and websockets
>>> through Nginx with Nginx handling the SSL certs.
>>>
>>> Once I tried to offloading SSL certs to the ELB so I could capture
>>> X-Forwarded-For, websockets fail to route/upgrade to Daphne and I get "Not
>>> Found: /ws/" in uwsgi's logs.
>>>
>>> Here is the relevant (working) piece of Nginx .conf file using TCP/443
>>> pass thru from the ELB:
>>>
>>> location /ws {
>>> proxy_pass http://unix:/opt/toogo/run/r117.0.4.3720.ws;
>>>  #Obviously daphne is listening here
>>> proxy_set_header Upgrade $http_upgrade;
>>> proxy_set_header Connection "upgrade";
>>> proxy_http_version 1.1;
>>> proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
>>> proxy_set_header Host $host;
>>> }
>>>
>>> What change is required if I offload the SSL certs to the ELB and
>>> introduce X-Forwarded-for?
>>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/305b31ae-ff69-425a-a173-645c55ba07a1%40googlegroups.com
>> 
>> .
>>
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/iNoIPxDgv90/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> django-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHAc2jf1KNYe-p2JM-XLD2q8HpC_29oNrJ24KkyjVFRj%2BpPo%2BQ%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK09zoq2pD6MsMfXA6y_rj4CUvcxgrT-w11xYCSvaUjdm8TD_Q%40mail.gmail.com.


Re: Channels/Redis fault tolerance with Twemproxy?

2018-08-05 Thread Tim Nelson
For sure, in order to support haproxy/redis-sentinel asgi_redis would have
to handle redis-py's   ReadOnlyError and reopen the connection. Way above
my pay grade to inject this into 1.X.  It seems 2.X might suffer from the
same issue as I don't see it handling this condition either.  Still baffles
me no one is using some for of fault-tolerant Redis in production yet.
Surely others must have been bitten by this already.

I'll have to weigh the merits (and pain) of migrating to Channels 2 this
late in the game, we don't have many consumers, but we do some funky things
with session data since we are multi-tenant.


On Sun, Aug 5, 2018 at 2:53 PM Andrew Godwin  wrote:

> Channels 1 and its Redis bindings have different behaviours to 2, so this
> might be improved there (but I can't guarantee it).
>
> Andrew
>
> On Sun, Aug 5, 2018 at 11:48 AM Filbert  wrote:
>
>> Wow, I thought I had this working using haproxy in front of
>> redis-sentinel.  haproxy fails over when redis-sentinel fails over within
>> 30 seconds.
>>
>> Problem is Daphne (Channels 1.X), reports over and over:
>>
>> Error trying to receive messages: Error running script (call to
>> f_3640886a0c8901ca9188f5f7a5f7a346145b9c5f): @user_script:3: @user_script:
>> 3: -READONLY You can'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:
>>>
>>> Yup, any sort of TCP-level proxy with failover will work for this sort
>>> of thing, but you'll likely see some errors whenever you failover as
>>> Channels loses its blocking connection that it's using to wait for messages
>>> - as always, please test a failover before you rely on it!
>>>
>>> Andrew
>>>
>>> On Thu, Aug 2, 2018 at 5:50 PM Filbert  wrote:
>>>
 Andrew,
 Just to be clear, there is no reason I can't use haproxy to front end
 redis sentinel to effectively hide all this from channels 1 or 2 right?
 Very surprised there isn't anyone running this in production that doesn'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:
>
> The Sentinel option was removed in the 2.0 rewrite as it didn't have
> someone to help maintain it (I didn't have the time then and don't right
> now), so you are right, there's currently no easy HA option for Redis with
> Channels.
>
> If you're interested in one, I can give you some tips on what code
> needs to be written, but it's not something I really want to maintain
> myself as part of the greater Channels effort as HA solutions tend to be
> quite workload-heavy to develop and test and end up being specific to
> certain deployment scenarios. Contributions of code that could help are
> welcome, though.
>
> Andrew
>
> On Wed, Aug 1, 2018 at 1:22 PM Filbert  wrote:
>
>> Well in digging through posts I see Sentinel may be an option, does
>> that mean if my CHANNEL_LAYER would have a single host entry?
>>
>> On Wednesday, August 1, 2018 at 9:42:39 AM UTC-4, Filbert wrote:
>>>
>>> Thanks Andrew,
>>> So with a load-balanced ten web server implementation using Channels
>>> (and of course ten instances of redis) do I have a HA solution then?  
>>> RIght
>>> now Django settings simply has a list of those servers in 
>>> CHANNEL_LAYERS,
>>> what if (say) 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, July 22, 2018 at 8:09:16 PM UTC-4, Andrew Godwin wrote:

 I don't think redis-cluster supports BLPOP properly still so I
 don't think you can use it.

 Andrew

 On Sun, Jul 22, 2018 at 12:46 PM Filbert  wrote:

> And just to be clear as to my options, using Channels 2.0 I can
> use Redis cluster if I have to to get failover and fault tolerance, 
> 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
>>
>> 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 Redis Cluster or Redis
>>> sentinel.  Is a decent