pusher-http-rust icon indicating copy to clipboard operation
pusher-http-rust copied to clipboard

Allow cluster to be set when creating new client

Open wmonk opened this issue 7 years ago • 4 comments

Hey!

I managed to get my pusher client working by using from_url and specifying something like:

let mut pusher = Pusher::from_url("http://<key>:<secret>@api-<cluster>.pusher.com/apps/<app_id>").finalize();

Currently we are also using the python version of this module, which allows you to set the cluster. It would be good to document how to get this setup - like the above, or to expose a method to set it on the PusherBuilder struct.

Not sure if the way i've implemented above is the desired way, or if it just hasn't been a requirement yet, but it seems to be required functionality in the other pusher clients.

Hope this make sense!

wmonk avatar Feb 22 '18 13:02 wmonk

Oh also, I wasn't able to use https in the way above, or even .secure(), it kept raising an exception like:

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Io(Error { repr: Custom(Custom { kind: InvalidInput, error: StringError("Invalid scheme for Http") }) })', src/libcore/result.rs:916:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

wmonk avatar Feb 22 '18 13:02 wmonk

The doesn't exist becuase the library was built before Pusher released support for multiple clusters and this library has not been updated to support it.

Having it as a method on the PusherBuilder struct would be good. I'll give it a go if I get the chance. Also happy to accept PRs!

As for your second comment, that definitely looks like a bug that should be fixed.

WillSewell avatar Feb 22 '18 13:02 WillSewell

Ah that makes sense! I'm not really well versed in Pusher docs, just reimplementing some stuff at work that is already using it. Let me see if I can find some time to open a PR 😄

wmonk avatar Feb 22 '18 22:02 wmonk

I was having this issue as well and was able to set cluster with;

 let pusher = pusher::PusherBuilder::from_url(&format!(
        "http://{pusher_key}:{pusher_secret}@api-{cluster}.pusher.com/apps/{pusher_app_id}"
    ))
    .finalize();

matthiasdebernardini avatar Jul 27 '23 18:07 matthiasdebernardini