ably / ably-java

Java, Android, Clojure and Scala client library SDK for Ably realtime messaging service
https://ably.com/download
Apache License 2.0
86 stars 39 forks source link

Regression in 1.0 ? #317

Closed ousenko closed 7 years ago

ousenko commented 7 years ago

Dear Ably staff,

In this issue you suggested I update to 1.0

I did. And it broke everything :-)

My code for initializing ART is and was:

...    
       ClientOptions options = new ClientOptions(BuildConfig.ABLY_API_KEY);
        options.logLevel = io.ably.lib.util.Log.VERBOSE;
        options.httpOpenTimeout = 20000;
        options.httpRequestTimeout = 30000;
//        String realtimeHost = options.realtimeHost;
//        String restHost = options.restHost;
//        options.realtimeHost = "MY_SECRET_APP-" + realtimeHost; // in 0.8.4 it becomes MY_SECRET_APP-realtime.ably.io
//        options.restHost = "MY_SECRET_APP-" + restHost; // in 0.8.4 it becomes MY_SECRET_APP-rest.ably.io

        ably = new AblyRealtime(options);
....

Commented are the lines that worked like charm in 0.8.4 of lib. More - nothing worked if I didn't specify these hosts in 0.8.4 manually.

Now these lines useless, because in 1.0 options.restHost and options.realtimeHost are null by default. In 0.8.4 I spied them to be realtime.ably.io and rest.ably.io by default - and it required me to specify "MY_SECRET_APP-" prefix for these hosts

Now with the lines above I get:

03-16 12:58:10.781 29497-29497/com.my_secret_app.stage I/System.out: (INFO): io.ably.lib.realtime.AblyRealtime: started
03-16 12:58:10.782 29497-29497/com.my_secret_app.stage I/System.out: (INFO): Auth(): anonymous, using basic auth
03-16 12:58:10.785 29497-29533/com.my_secret_app.stage I/art: Waiting for a blocking GC Explicit
03-16 12:58:10.799 29497-29497/com.my_secret_app.stage I/System.out: (VERBOSE): io.ably.lib.transport.ConnectionManager: requestState(): requesting connecting; id = null
03-16 12:58:10.801 29497-29682/com.my_secret_app.stage I/System.out: (VERBOSE): io.ably.lib.transport.ConnectionManager: notifyState(): notifying connecting; id = null
03-16 12:58:10.801 29497-29682/com.my_secret_app.stage I/System.out: (VERBOSE): io.ably.lib.transport.ConnectionManager: setState(): setting connecting
03-16 12:58:10.804 29497-29682/com.my_secret_app.stage I/System.out: (DEBUG): io.ably.lib.transport.ITransport: getConnectParams: params = [key:objr_Q.NbzT_w:7e7RBTb0znGIzj8y, v:0.9, format:msgpack, heartbeats:false, lib:java-1.0.0]
03-16 12:58:10.853 29497-29497/com.my_secret_app.stage E/SafeGraphics: Created graphics com.badlogic.gdx.backends.android.SafeGraphics@a3646c8
03-16 12:58:10.853 29497-29533/com.my_secret_app.stage I/art: WaitForGcToComplete blocked for 68.488ms for cause Explicit
03-16 12:58:10.853 29497-29533/com.my_secret_app.stage I/art: Starting a blocking GC Explicit
03-16 12:58:10.940 29497-29533/com.my_secret_app.stage I/art: Explicit concurrent mark sweep GC freed 3520(260KB) AllocSpace objects, 0(0B) LOS objects, 40% free, 12MB/21MB, paused 1.443ms total 85.792ms
03-16 12:58:11.474 29497-29497/com.my_secret_app.stage I/System.out: (VERBOSE): io.ably.lib.realtime.Channel: RealtimeChannel(); channel = game:gtest_2e6214260fae8593068b0f0de21e5694
03-16 12:58:11.477 29497-29497/com.my_secret_app.stage I/System.out: (VERBOSE): io.ably.lib.realtime.Channel: subscribe(); channel = game:gtest_2e6214260fae8593068b0f0de21e5694
03-16 12:58:11.479 29497-29497/com.my_secret_app.stage I/System.out: (VERBOSE): io.ably.lib.realtime.Channel: attach(); channel = game:gtest_2e6214260fae8593068b0f0de21e5694
03-16 12:58:11.480 29497-29497/com.my_secret_app.stage I/System.out: (VERBOSE): io.ably.lib.realtime.Channel: setState(): channel = game:gtest_2e6214260fae8593068b0f0de21e5694; setting attaching
03-16 12:58:11.535 29497-29497/com.my_secret_app.stage E/GameViewController: Init: setting players: size 11
03-16 12:58:11.552 29497-29687/com.my_secret_app.stage I/System.out: (VERBOSE): io.ably.lib.transport.ConnectionManager: onMessage(): error: {"action":9,"count":0,"error":{"code":40300,"message":"Account disabled","statusCode":403},"flags":0,"timestamp":1489654690201}
03-16 12:58:11.552 29497-29687/com.my_secret_app.stage I/System.out: (ERROR): io.ably.lib.transport.ConnectionManager: onMessage(): ERROR message received; message = Account disabled; code = 40300
03-16 12:58:11.553 29497-29687/com.my_secret_app.stage I/System.out: (VERBOSE): io.ably.lib.transport.ConnectionManager: notifyState(): notifying failed; id = null

If I revert to 0.8.4 and uncomment lines everything works

Guys, taking into consideration this and this, - could you hint me on ways to resolve that issue, and provide any ETAs on fixing these issues ?

For now I decided to manually specify these hosts, but I feel this is a very temporary approach and that design, distribution and documentation problems of Ably Java lib should be taken care of.

@mattheworiordan @paddybyers @SimonWoolf

paddybyers commented 7 years ago

I'm looking now.

paddybyers commented 7 years ago

Commented are the lines that worked like charm in 0.8.4 of lib. More - nothing worked if I didn't specify these hosts in 0.8.4 manually.

The 1.0 spec includes a ClientOptions.environment field, which you should use if you want to override the default hosts. Pre-1.0 libraries all did something slightly different, and the behaviour you were relying on - that the realtimeHost and restHost would be pre-populated - was undocumented behaviour specific to the older version of the java library only.

So now you would just set

options.environment = "MY_SECRET_APP-";

We don't document this option in the main documentation because users are not generally expected to use custom environments, but this is speciifed in the library specification; see https://docs.ably.io/client-lib-development-guide/features/#RSC11 for details.

mattheworiordan commented 7 years ago

So now you would just set options.environment = "MY_SECRET_APP-";

Please note that would actually be options.environment = "MY_SECRET_APP" as that would then result in the rest host changing to MY_SECRET_APP-rest.ably.io and realtime to MY_SECRET_APP-realtime.ably.io. i.e. you don't need the trailing hyphen

ousenko commented 7 years ago

@paddybyers @mattheworiordan right now I'm using explicit MY_SECRET_APP-rest.ably.io , seems to be working approach, too

mattheworiordan commented 7 years ago

I'm using explicit MY_SECRET_APP-rest.ably.io , seems to be working approach, too

You mean as a host? I would recommend you use environment to be honest, but explicitly setting the restHost and realtimeHost does work.

Mind if I ask what environment you are using? You an email us at support@ably.io if you don't want to publish here.

ousenko commented 7 years ago

Mailed