Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Channel is closed #580

Open
mofibo opened this issue Sep 20, 2023 · 0 comments
Open

Channel is closed #580

mofibo opened this issue Sep 20, 2023 · 0 comments

Comments

@mofibo
Copy link

mofibo commented Sep 20, 2023

Hello lads,

I just want to know if there is a specific time to publish the message after reading it when using aiopika, because when i tried a process that takes a few time, I get "channel is closed" when publishing the message, here is a part of a test code I used:

    async def connect(self):
        self.connection = await connect_robust(
            host=RABBITMQ_HOST,
            port=RABBITMQ_PORT,
            login=USERNAME,
            password=PASSWORD_RMQ,
            virtualhost=VIRTUAL_HOST,
            loop=self.loop,
        )

        # Creating a channel
        self.channel = await self.connection.channel()
        await self.channel.set_qos(1)

        # Declaring queue
        self.queue = await self.channel.declare_queue(
            env_var.MAIN_QUEUE, arguments={"x-message-ttl": self.TTL_VALUE}
        )

        await self.queue.consume(
            partial(self.on_message, self.channel.default_exchange)
        )

        return 
async def on_message(self, exchange: Exchange, message: IncomingMessage):
        with message.process():
                    time.sleep(200) # this is to replace the process, so i can get "channel is closed" 
                    await exchange.publish(
                        Message(
                            body=output_msg.SerializeToString(),
                            correlation_id=message.correlation_id,
                        ),
                        routing_key=message.reply_to,
                    )

For what reason the publish doesn't work and i receive channel is close?
I'm using aio-pika 6.8.1

Thank you in advance.
Regards

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

No branches or pull requests

1 participant