Channels: starting Daphne in production

95 views
Skip to first unread message

Filbert

unread,
Dec 12, 2017, 6:14:59 PM12/12/17
to Django users
Trying to come up with the proper command line to start Daphne in production.  It seems when I start, it heads off into a repeated processing loop, my thought is that it should just be pending on a websocket connection. Using asgi_rabbitmq.

daphne -u /opt/daphne.sock  --ws-protocol "graphql-ws" --proxy-headers -v 2 asgi:channel_layer

Seems to be repeated logging:

Calling <bound method LayerChannel._on_synchronous_complete of <LayerChannel number=2 OPEN conn=<LayerConnection OPEN socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/ ssl=False>>>> for "2:Queue.DeclareOk"
0 blocked frames
Calling functools.partial(<bound method Protocol.queues_declared of <asgi_rabbitmq.core.Protocol object at 0x7f1cd01f6a20>>, {'daphne.response.yLFVcixMCk!'}, set(), ['daphne.response.yLFVcixMCk!'], False) for "2:Queue.DeclareOk"
Added: {'arguments': None, 'only': None, 'calls': 1, 'callback': functools.partial(<bound method Protocol.no_message of <asgi_rabbitmq.core.Protocol object at 0x7f1cd01f6a20>>, []), 'one_shot': True}
Processing 2:Basic.GetEmpty
Processing use of oneshot callback
0 registered uses left


Any debugging ideas?

Entering IOLoop
Connecting to 127.0.0.1:5672
Processing 0:Connection.Start
Processing use of oneshot callback
0 registered uses left
Removing callback #0: {'arguments': None, 'only': None, 'calls': 0, 'callback': <bound method LayerConnection._on_connection_start of <LayerConnection PROTOCOL socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/ ssl=False>>>, 'one_shot': True}
Calling <bound method LayerConnection._on_connection_start of <LayerConnection PROTOCOL socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/ ssl=False>>> for "0:Connection.Start"
Added: {'arguments': None, 'only': None, 'calls': 1, 'callback': <bound method LayerConnection._on_connection_tune of <LayerConnection START socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/
ssl=False>>>, 'one_shot': True}
Processing 0:Connection.Tune
Processing use of oneshot callback
0 registered uses left
Removing callback #0: {'arguments': None, 'only': None, 'calls': 0, 'callback': <bound method LayerConnection._on_connection_tune of <LayerConnection START socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/ ssl=False>>>, 'one_shot': True}
Calling <bound method LayerConnection._on_connection_tune of <LayerConnection START socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/ ssl=False>>> for "0:Connection.Tune"
Creating a HeartbeatChecker: 600
add_timeout: added timeout -1786684229378238513; deadline=600 at 1513095706.3193622
Added: {'arguments': None, 'only': None, 'calls': 1, 'callback': <bound method LayerConnection._on_connection_open of <LayerConnection TUNE socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/
ssl=False>>>, 'one_shot': True}
Processing 0:Connection.OpenOk
Processing use of oneshot callback
0 registered uses left
Removing callback #0: {'arguments': None, 'only': None, 'calls': 0, 'callback': <bound method LayerConnection._on_connection_open of <LayerConnection TUNE socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/ ssl=False>>>, 'one_shot': True}
Calling <bound method LayerConnection._on_connection_open of <LayerConnection TUNE socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/ ssl=False>>> for "0:Connection.OpenOk"
Processing 0:_on_connection_open
Calling <bound method RabbitmqConnection.start_loop of <asgi_rabbitmq.core.RabbitmqConnection object at 0x7f1cbcf349b0>> for "0:_on_connection_open"
Added: {'arguments': None, 'only': <LayerChannel number=1 CLOSED conn=<LayerConnection OPEN socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/
ssl=False>>>, 'calls': 1, 'callback': <bound method LayerConnection._on_channel_cleanup of <LayerConnection OPEN socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/ ssl=False>>>, 'one_shot': True}
Added: {'arguments': None, 'only': None, 'callback': <bound method LayerChannel._on_getempty of <LayerChannel number=1 OPENING conn=<LayerConnection OPEN socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/
ssl=False>>>>, 'one_shot': False}
Added: {'arguments': None, 'only': None, 'callback': <bound method LayerChannel._on_cancel of <LayerChannel number=1 OPENING conn=<LayerConnection OPEN socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/ ssl=False>>>>, 'one_shot': False}
Added: {'arguments': None, 'only': None, 'callback': <bound method LayerChannel._on_flow of <LayerChannel number=1 OPENING conn=<LayerConnection OPEN socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/
ssl=False>>>>, 'one_shot': False}
Added: {'arguments': None, 'only': None, 'calls': 1, 'callback': <bound method LayerChannel._on_close of <LayerChannel number=1 OPENING conn=<LayerConnection OPEN socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/ ssl=False>>>>, 'one_shot': True}
Entering blocking state on frame <Channel.Open(['out_of_band='])>; acceptable_replies=[<class 'pika.spec.Channel.OpenOk'>]
Adding on_synchronous_complete callback
Added: {'arguments': None, 'only': None, 'calls': 1, 'callback': <bound method LayerChannel._on_synchronous_complete of <LayerChannel number=1 OPENING conn=<LayerConnection OPEN socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/
ssl=False>>>>, 'one_shot': True}
Adding passed-in callback
Added: {'arguments': None, 'only': None, 'calls': 1, 'callback': <bound method LayerChannel._on_openok of <LayerChannel number=1 OPENING conn=<LayerConnection OPEN socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/ ssl=False>>>>, 'one_shot': True}
Added: {'arguments': None, 'only': <LayerChannel number=2 CLOSED conn=<LayerConnection OPEN socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/
ssl=False>>>, 'calls': 1, 'callback': <bound method LayerConnection._on_channel_cleanup of <LayerConnection OPEN socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/ ssl=False>>>, 'one_shot': True}
Added: {'arguments': None, 'only': None, 'callback': <bound method LayerChannel._on_getempty of <LayerChannel number=2 OPENING conn=<LayerConnection OPEN socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/
ssl=False>>>>, 'one_shot': False}
Added: {'arguments': None, 'only': None, 'callback': <bound method LayerChannel._on_cancel of <LayerChannel number=2 OPENING conn=<LayerConnection OPEN socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/ ssl=False>>>>, 'one_shot': False}
Added: {'arguments': None, 'only': None, 'callback': <bound method LayerChannel._on_flow of <LayerChannel number=2 OPENING conn=<LayerConnection OPEN socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/
ssl=False>>>>, 'one_shot': False}
Added: {'arguments': None, 'only': None, 'calls': 1, 'callback': <bound method LayerChannel._on_close of <LayerChannel number=2 OPENING conn=<LayerConnection OPEN socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/ ssl=False>>>>, 'one_shot': True}
Entering blocking state on frame <Channel.Open(['out_of_band='])>; acceptable_replies=[<class 'pika.spec.Channel.OpenOk'>]
Adding on_synchronous_complete callback
Added: {'arguments': None, 'only': None, 'calls': 1, 'callback': <bound method LayerChannel._on_synchronous_complete of <LayerChannel number=2 OPENING conn=<LayerConnection OPEN socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/
ssl=False>>>>, 'one_shot': True}
Adding passed-in callback
Added: {'arguments': None, 'only': None, 'calls': 1, 'callback': <bound method LayerChannel._on_openok of <LayerChannel number=2 OPENING conn=<LayerConnection OPEN socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/ ssl=False>>>>, 'one_shot': True}
Processing 1:Channel.OpenOk
Processing use of oneshot callback
0 registered uses left
Removing callback #0: {'arguments': None, 'only': None, 'calls': 0, 'callback': <bound method LayerChannel._on_synchronous_complete of <LayerChannel number=1 OPENING conn=<LayerConnection OPEN socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/
ssl=False>>>>, 'one_shot': True}
Processing use of oneshot callback
0 registered uses left
Removing callback #0: {'arguments': None, 'only': None, 'calls': 0, 'callback': <bound method LayerChannel._on_openok of <LayerChannel number=1 OPENING conn=<LayerConnection OPEN socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/ ssl=False>>>>, 'one_shot': True}
Calling <bound method LayerChannel._on_synchronous_complete of <LayerChannel number=1 OPENING conn=<LayerConnection OPEN socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/ ssl=False>>>> for "1:Channel.OpenOk"
0 blocked frames
Calling <bound method LayerChannel._on_openok of <LayerChannel number=1 OPENING conn=<LayerConnection OPEN socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/
ssl=False>>>> for "1:Channel.OpenOk"
Entering blocking state on frame <Exchange.Declare(['arguments={}', 'auto_delete=False', 'durable=False', 'exchange=dead-letters', 'internal=False', 'nowait=False', 'passive=False', 'ticket=0', 'type=fanout'])>; acceptable_replies=[<class 'pika.spec.Exchange.DeclareOk'>]
Adding on_synchronous_complete callback
Added: {'arguments': None, 'only': None, 'calls': 1, 'callback': <bound method LayerChannel._on_synchronous_complete of <LayerChannel number=1 OPEN conn=<LayerConnection OPEN socket=('127.0.0.1', 34690)->('127.0.0.1', 5672) params=<URLParameters host=rabbitmq port=5672 virtual_host=/ ssl=False>>>>, 'one_shot': True}

Andrew Godwin

unread,
Dec 12, 2017, 6:33:55 PM12/12/17
to django...@googlegroups.com
Hm, that looks to be like logging from asgi_rabbitmq - could you post your settings configuration? And have you tried running with a different channel layer?

Andrew

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/38e740e9-6b6e-4efb-92f6-8e23c0aa6252%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Filbert

unread,
Dec 12, 2017, 7:01:18 PM12/12/17
to Django users
Yes, using rabbit...

CHANNEL_LAYERS = {
   
'default': {
       
'BACKEND': 'asgi_rabbitmq.RabbitmqChannelLayer',
       
'ROUTING': 'toogo.routing.channel_routing',
       
'CONFIG': {
           
'url': 'amqp://foo:bar@{0}:5672/%2F'.format(RABBITMQ_NODE),
       
},
   
},
}



This of course works fine (but we are clustering web servers):
 
   CHANNEL_LAYERS = {
       
"default": {
           
"BACKEND": "asgiref.inmemory.ChannelLayer",
           
"ROUTING": "toogo.routing.channel_routing",
       
},
   
}
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.

Filbert

unread,
Dec 12, 2017, 7:11:44 PM12/12/17
to Django users
Also, curiously, when I use Inmemory, it seems to connect and immediately disconnect. Hopefully my Nginx conf makes sense.

location /ws {
                proxy_pass http
://unix:/tmp/daphne.ws;
                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;
       
}
Added: {'arguments': None,<span style="color:#000"

Filbert

unread,
Dec 12, 2017, 8:08:08 PM12/12/17
to Django users
More specifically, it is logging:

None - - [12/Dec/2017:20:06:39] "WSCONNECTING /ws/" - -
DEBUG Upgraded connection daphne.response.HKlOHkryrd!VaSFKIooRZ to WebSocket daphne.response.HKlOHkryrd!XdRRyyAyVn
DEBUG WebSocket closed for daphne.response.HKlOHkryrd!XdRRyyAyVn
None - - [12/Dec/2017:20:06:43] "WSDISCONNECT /ws/" - -

Filbert

unread,
Dec 12, 2017, 11:32:38 PM12/12/17
to Django users
Worried I am connecting, but some initial negotiation isn't occurring when I am using Daphne vs. runserver. I even proved this by starting runserver with --noasgi and running daphne by hand on my desktop and I get the same connect/disconnect pattern.

I saw this note, but I am not sure why this isn't failing under runserver as well. Running latest Channels BTW.

WebSocket accept/reject flow

Rather than be immediately accepted, WebSockets now pause during the handshake while they send over a message on websocket.connect, and your application must either accept or reject the connection before the handshake is completed and messages can be received.

You must update Daphne to at least 1.0.0 to make this work correctly.

Filbert

unread,
Dec 13, 2017, 1:01:18 AM12/13/17
to Django users
Uhh...could it be as simple as not having a worker running?

Andrew Godwin

unread,
Dec 13, 2017, 7:50:11 AM12/13/17
to django...@googlegroups.com
Not having a worker running would definitely do it (without one requests will just hang forever until the timeout kicks in). It's worth making sure it serves HTTP pages first as those are much harder to screw up with accept/reject flows on your end.

Andrew

--
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+unsubscribe@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
Reply all
Reply to author
Forward
0 new messages