AtherEnergy / rumqtt

Pure rust mqtt cilent
The Unlicense
202 stars 71 forks source link

tokio2 branch's tls connection doesn't work with clean_session=false #61

Closed tekjar closed 6 years ago

nanomad commented 6 years ago

@tekjar I think I found it.

I have no idea why it wasn't working as I'm not even a tokio newbie but something was going wrong in republish_unacked of connection.rs when publishes was an Vec of len 0. Making handle_reconnection return a None in that case fixes the issue.

I've added a test case as well

tekjar commented 6 years ago

Ok I think there is no problem with this. I was testing this with aws iot and it doesn't seem to support persistent sessions (and I don't know how to check the reason for disconnection on aws). Tls is working for me locally.

@nanomad I think this is a different issue. I'll verify this.

nanomad commented 6 years ago

@tekjar You can use the free plan on CloudMQTT to test it.

I've configured it using the following as the CA cert bundle:

"C:\OpenSSL-Win64\certs\cacert.pem"

tekjar commented 6 years ago

@nanomad

This is happening because Framed is not able to continue after handling bounded streams

nanomad commented 6 years ago

Ah, makes sense. I'll work on it a little bit. It's a good way of learning about tokio2 anyway

nanomad commented 6 years ago

So, after looking at https://github.com/alexcrichton/futures-rs/issues/462 it seems like both stream's join as well as sink's send_all flush and close the sink at the end which is no bueno.

I suppose the solution is to iterate over the packets sending them one by one. I'll see what I can come up...

nanomad commented 6 years ago

@tekjar Should be fixed in #67 Took me way too much than I care to admit to figure out how to write the loop properly