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

invalid channel: 0 error #382

Closed
luca-iachini opened this issue Jul 12, 2023 · 9 comments
Closed

invalid channel: 0 error #382

luca-iachini opened this issue Jul 12, 2023 · 9 comments

Comments

@luca-iachini
Copy link

luca-iachini commented Jul 12, 2023

Hello,
first of all, thanks for the great library.
sometimes, I receive Invalid channel: 0 when I publish a message on a queue, do you know why that happens?
The following is the piece of code that raises the error:

fn send_message(msg: &[u8]) -> Result<()> {
        let conn = Connection::connect(&addr, ConnectionProperties::default()).await?;
        let channel = conn.create_channel().await?;
        channel
            .basic_publish(
                "",
                "messages",
                BasicPublishOptions::default(),
                msg,
                BasicProperties::default(),
            )
            .await?;
       Ok(())
}

That function opens a new connection, creates a channel, and sends a message on every invocation.
When I see that error, the client sent the message successfully, so it does not impact the normal flow of the application.
I guess that the client receives messages from the server after it dropped channel 0.

Any help would be very appreciated.

@Keruspe
Copy link
Collaborator

Keruspe commented Jul 12, 2023

That’s interesting. My guess is the same as yours.
Any reason why you’re not reusing the connection and/or channel out of curiosity?

@luca-iachini
Copy link
Author

That example is taken from a test. it occurs more frequently in cases where the connection is dropped immediately after usage.

@Keruspe
Copy link
Collaborator

Keruspe commented Jul 12, 2023

Right!
Minimal reproducers are indeed always greatly appreciated.
You might be in luck as I might have time to debug this tonight.
Would you happen to have a test account on a server where you can reproduce it? It sometimes can depend on the server and/or network route leading to it.

@luca-iachini
Copy link
Author

sorry, I don't have a test account to share. Good to know that you have time to debug it 😃

@oliverbrowneprima
Copy link

oliverbrowneprima commented Jul 14, 2023

Hey @Keruspe, after a little digging (I work with @luca-iachini, for reference), I have a question about the logic of Channels::set_connection_closed - it drains the channels map, sending an internal rpc RemoveChannel command for each found channel, which results in a call to Channels::remove, which tries to remove the channel from the channels internal map... which has just been drained?

Isn't that a double-remove? I know I must be missing something, since this error isn't perfectly reproducible?

EDIT: whoops, looks like you beat me too it 😄. Thanks!

@Keruspe
Copy link
Collaborator

Keruspe commented Jul 14, 2023

It doesn’t send a RemoveChannel IPC there btw

@oliverbrowneprima
Copy link

oliverbrowneprima commented Jul 14, 2023

Channel::set_closed calls InternalRPCHandle::remove_channel no?

Sorry I'm purely satisfying my curiosity here, to be clear.

@Keruspe
Copy link
Collaborator

Keruspe commented Jul 14, 2023

You are absolutely right.
Just did some more tests and we can simplify all of this!

@oliverbrowneprima
Copy link

You are absolutely right. Just did some more tests and we can simplify all of this!

Wooo! 🥳

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

3 participants