Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

Broker connection still open #76

Closed
Zeniox opened this issue Sep 12, 2016 · 4 comments
Closed

Broker connection still open #76

Zeniox opened this issue Sep 12, 2016 · 4 comments

Comments

@Zeniox
Copy link

Zeniox commented Sep 12, 2016

Hi!!

I have a problem, with rabbitq as broker, I see in RabbitMQ Management (in Connections tab) my php script leave always one connection open in every server call.

I will try to explain myself, sorry for my awful english.

My requirements are very simple, my tasks dosen´t need confirmations and I don´t need results tasks, in fact, Celery is working without backend track, I mean: CELERY_RESULT_BACKEND = 'disabled://'

So my typical scenario is like:

.
.
.
$celery = new Celery('localhost','guest','guest','/');
$celery->PostTask("myuntrackedtask", $m_param , false);
.
.
(more my php stuff regardless of celery's world...)
.
.

I see in the RabbitMQ Management tab as connections opens, one for broker and one for backend (although I do not need backend), when the php script is finished one connection is closed but another one is still open... and accumulate along the time many open connections.

Please.. can anybody help me?

Thanks very much!!

Zeniox

@gjedeer
Copy link
Owner

gjedeer commented Sep 28, 2016

You could try explicitly destroying the object by calling uset($celery).

But maybe you could try using another backend (php-amqplib instead of PECL AMQP, or vice versa) - the back end library is supposed to close connections when the script finishes execution, if it does not, it's a bug.

For details on why we're not closing connections explicitly after posting a task, see #62

@Zeniox
Copy link
Author

Zeniox commented Oct 3, 2016

Thanks for your reply gjedeer ;)

Oh no, this is more simple, I traced the execution and find out this. (sorry for my awful english)

In celery.php , inside of BuildConnection function , the $this->isConnected class variable not is set to true , then in the PostTask function, in this lines...

if (!$this->isConnected) {
 $this->broker_amqp->Connect($this->broker_connection);
 $this->isConnected = true;
}

The script unknowns the opened connection and open another connection (two open connections now).
So, when the script ends, PECL AMQP, library close one connection, but the first (or the last i don´t know) is still open.. forever.

My solution??, in BuildConnection function, set $this->isConnected to true and works fine, obviously ;)

Thanks for your support gjedeer, and sorry for my delayed response, in this days i'm very busy...

@jdufresne
Copy link
Collaborator

@Zeniox the latest release, 2.1.2, has fixes with regards to reusing an open Celery connection. Can you upgrade and see if you're still experiencing the same issue. If so, could you provide a minimal test script that demonstrates the buggy behavior?

@jdufresne
Copy link
Collaborator

Closing until requested information is provided. If you can provide a minimal test script demonstrating the bug with the latest release or master branch, please reopen.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants