RandomEngy / fcm-push-listener

15 stars 1 forks source link

Listener connection failure #1

Closed Cm-c closed 1 year ago

Cm-c commented 1 year ago

Hi, I've started an example project with this and it successfully registers and receives the FCM Token, but then it fails upon connection to the listener with the following:

http(reqwest::Error { kind: Request, url: Url { scheme: "https", cannot_be_a_base: false, username: "", password: None, host: Some(Domain("android.clients.google.com")), port: None, path: "/checkin", query: None, fragment: None }, source: hyper::Error(Connect, ConnectError("dns error", Custom { kind: Interrupted, error: JoinError::Cancelled(Id(22)) })) })

To provide some context im on macOS, and can lookup this domain fine. Do you know what is going wrong here?

RandomEngy commented 1 year ago

Are you dropping the FcmPushListener after calling connect() ? When you drop that object, it will cancel the spawned task associated with it, which would explain why the DNS lookup on the checkin request was canceled.

RandomEngy commented 1 year ago

By the way I'm currently looking into changing this around so connect() returns a future instead of spawning a task. That would require a bit more work to allow proper cancellation (You'd need to wrap it in a task and abort the task), but then it's more obvious that it's doing work there. It would also let the message callback be a closure instead of a function pointer, which then could capture outside variables and be a lot easier to work with.

It would be a breaking API change, but this is my first Rust project and I'm still figuring some things out.

Cm-c commented 1 year ago

I'm not entirely sure, I'm not too familiar with Rust I just wanted to try this out because the counterparties in other languages haven't worked for me.

I noticed that the example in the documentation was failing in the sense that you were awaiting the listener connection despite that method not supporting it. Maybe in refactoring this I've messed something up.

I create a registration which I unwrap and pass into the creation of a listener, which I then attempt to connect. The only thing that I'm awaiting is the creation of the registration.

Regardless, very good work.

RandomEngy commented 1 year ago

I just released v2.0.0 and updated the documentation. The example should work now.