You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Several days ago I try to configure a celery worker running under SSL with a self-signed certificate. The broker that I using is RabbitMQ and try debugging all configurations without receiving errors in the certificate or in the configuration.
I configuring my worker without ssl and tasks are processed smoothly, but reactivating celery with ssl are not be processed again.
After various tests, a few hours ago can resolve the problem by adding the parameter "- without-mingle" to my startup script.
The line ran in both cases (with SSL and without SSL) was as follows:
@jonathanlb It appears this is a double stalling issue caused by buffering in pyamqp/amqplib/librabbitmq and the SSL wrappers from the socket module.
I've fixed (see #1847) pyamqp and amqplib to not buffer the reads (and prevent stalling) but the SSL socket wrapper can still stall (has own internal buffering). See man page for more details about this:
SSL_read() works based on the SSL/TLS records. The data are received in records (with a maximum record size of 16kB for SSLv3/TLSv1). Only when a record has been completely received, it can be processed (decryption and check of integrity). Therefore data that was not retrieved at the last call of SSL_read() can still be buffered inside the SSL layer and will be retrieved on the next call to SSL_read(). If num is higher than the number of bytes buffered, SSL_read() will return with the bytes buffered. If no more bytes are in the buffer, SSL_read() will trigger the processing of the next record.
I think best approach here (given current Hub implementation) is to add timers that generate fake Hub readiness events (so that these sockets get unstuck). @ask What do you think ?
Now that I think more about it I would think the current amqp protocol has some deficiency in the way it handles readiness - there are very many places that don't try very hard to exhaust the internal buffers and queues:
basically all forms of self.wait(allowed_methods=[ blaba ]) are vulnerable to stalling - cause they can leave unexpected (or more exactly, to be expected later) messages in the ssl buffers
Right, that would make sense but that does not really apply here when there is no request to read in the first place?
It would help with synchronous AMQP calls like queue.declare:
socket.write(create_queue_declare_frame())
socket.read() # <- wait for queue_declare_ok frame
But there is no 'wait for 1 message' call here, the broker simply sends new messages
as they are ready, without participation from the client.
So when using async I/O the only way to know that there is a new frame to be read
is when the socket is ready for read, and you cannot wake up to do dummy reads
at any reasonable interval without creating either a high frequency read loop or latency.
Forgot to say that yeah, I think calling drain_events at intervals of 1 second or so when using SSL would be the only solution (but that would also be the case in twisted, tornado, tulip if they don't have another way to solve it)
Activity
ionelmc commentedon Feb 8, 2014
This may be a the same buffering issue or something related to #1847 - watch that issue for fixes.
ionelmc commentedon Feb 8, 2014
@jonathanlb It appears this is a double stalling issue caused by buffering in pyamqp/amqplib/librabbitmq and the SSL wrappers from the socket module.
I've fixed (see #1847) pyamqp and amqplib to not buffer the reads (and prevent stalling) but the SSL socket wrapper can still stall (has own internal buffering). See man page for more details about this:
I think best approach here (given current Hub implementation) is to add timers that generate fake Hub readiness events (so that these sockets get unstuck). @ask What do you think ?
ask commentedon Feb 10, 2014
@ionelmc, I don't know, that could work I guess, what do other async libs do with SSL?
ionelmc commentedon Feb 10, 2014
I believe they don't stall because they optimize away polling (eg: try read first, if EAGAIN, then add in the poller). Examples:
Now that I think more about it I would think the current amqp protocol has some deficiency in the way it handles readiness - there are very many places that don't try very hard to exhaust the internal buffers and queues:
self.wait(allowed_methods=[ blaba ])are vulnerable to stalling - cause they can leave unexpected (or more exactly, to be expected later) messages in the ssl buffersask commentedon Feb 14, 2014
Right, that would make sense but that does not really apply here when there is no request to read in the first place?
It would help with synchronous AMQP calls like queue.declare:
But there is no 'wait for 1 message' call here, the broker simply sends new messages
as they are ready, without participation from the client.
So when using async I/O the only way to know that there is a new frame to be read
is when the socket is ready for read, and you cannot wake up to do dummy reads
at any reasonable interval without creating either a high frequency read loop or latency.
ask commentedon Feb 14, 2014
Forgot to say that yeah, I think calling
drain_eventsat intervals of 1 second or so when using SSL would be the only solution (but that would also be the case in twisted, tornado, tulip if they don't have another way to solve it)ask commentedon Jun 23, 2016
Closing this, as we don't have the resources to complete this task.