tristandunn / pusher-fake

A fake Pusher server for development and testing.
https://rubygems.org/gems/pusher-fake
MIT License
173 stars 32 forks source link

Usage with iOS and Android Clients with Java server? #69

Closed ScottPierce closed 2 years ago

ScottPierce commented 2 years ago

I see in your documentation for JS clients, you swap out the JS Client real instance for a fake instance. Is it possible to use this server with the Pusher Android and iOS clients?

My server is also java based, so I use the Java server sdk as well.

I see options in all the SDKs for setting host and port, so it seems like maybe yes, but then I'm not sure since your documentation doesn't say anything about this, and I don't understand why you'd be swapping out the JS client for a fake one.

I'd love your thoughts!

tristandunn commented 2 years ago

If you're not using Ruby, you can run the server via the binary. The method used for the JavaScript is simply a helper to turn the configuration into options for the JS client. So as long as the options provided to the binary server are used in the Android, Java, and iOS clients, specifically the web and socket host and port, it should "just work."

Hope that helps! Let me know if you have any issues.

ScottPierce commented 2 years ago

So my plan is to just setup your docker container in my docker-compose local dev setup, point my clients at it, and I should be good to go?

That's what I thought. Awesome! Thanks!

ScottPierce commented 2 years ago

Oh - you don't have a docker image. Looks like I can create an updated one based on https://github.com/gregeinfrank/docker-pusher-fake

ScottPierce commented 2 years ago

So how should I configure this for the server?

Some options I have on the server sdk:

Some options i have on the client sdk:

I don't seem to have the ability to set the port as I thought, but perhaps I can set it through the host? That doesn't really give me the ability to differentiate between a web port and a socket port though.

FYI - https://github.com/scottpierce/docker-pusher-fake

tristandunn commented 2 years ago

Oh - you don't have a docker image.

I'll look into adding an official one soon.

So how should I configure this for the server?

If you're using pusher-websocket-java, it looks like you can set the WebSocket port with setWsPort or setWssPort depending if you're using TLS or not. As far as I can tell it only uses HTTP for the HttpAuthorizer, which isn't related to the fake.

For the client, it may be similar but I'm not sure which libraries you're using. I'd look into how they work, as they may also only use a WebSocket as well.

And of course you'd only need HTTP configured correctly if you're using any of the endpoints.

ScottPierce commented 2 years ago

it looks like you can set the WebSocket port with setWsPort or setWssPort

Can't believe I missed that!

So here are the options:

$ pusher-fake --help
Usage: pusher-fake [options]
    -i, --id ID                      Use ID as the application ID for Pusher
    -k, --key KEY                    Use KEY as the key for Pusher
    -s, --secret SECRET              Use SECRET as the secret token for Pusher
        --socket-host HOST           Use HOST for the web socket server
        --socket-port PORT           Use PORT for the web socket server
    -v, --[no-]verbose               Run verbosely
        --web-host HOST              Use HOST for the web server
        --web-port PORT              Use PORT for the web server
        --webhooks URLS              Use URLS for the webhooks
  1. So I'm assuming setWsPort and setWssPort correspond to --socket-port depending on whether or not setUseTLS is true or false.
  2. Beyond that I just set setHost to http://localhost?
  3. I'm assuming setCluster shouldn't matter?

Do you think I should need to do anything else?

tristandunn commented 2 years ago

Yeah, you probably want to use setWsPort and not use TLS locally to make it easier, otherwise you have to deal with SSL. And localhost will work for the host assuming that's where it'll be available from Docker. You probably don't want setCluster since it changes the host and ports.

tristandunn commented 2 years ago

Guessing you worked this out so going to close, but feel free to re-open if needed.