Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop reconnecting #189

Closed
skadyrov opened this issue Oct 18, 2018 · 4 comments · Fixed by #328
Closed

Stop reconnecting #189

skadyrov opened this issue Oct 18, 2018 · 4 comments · Fixed by #328

Comments

@skadyrov
Copy link

What is the issue?

I am using this library in an Android app. My desired behavior when the app goes into background:

  1. Disconnect if already connected
  2. Stop reconnecting if it was not connected yet.

For disconnecting I use method:

pusher.disconnect()

So far it works fine if the connection state is ConnectionState.CONNECTED.

However, if the connection state was ConnectionState.CONNECTING or ConnectionState.RECONNECTING, using the disconnect() method doesn't stop the pusher from attempting to connect. I also did not find any other way to stop attempting to reconnect without having to implement a workaround. It would be nice to have a functionality to do both of the steps I described directly with pusher.

Is it a crash report?

  • No

Any improvements you suggest

...


CC @pusher/mobile

@jmanini
Copy link

jmanini commented Nov 10, 2018

I agree it would be helpful to stop reconnecting attempts. My workaround has been to check for spurious connection when ConnectionState.CONNECTED and then invoke pusher.disconnect().

@skadyrov
Copy link
Author

@jmanini I used the same workaround :)

@petarmarijanovicfive
Copy link

Still no improvement here? 😁

@Vlad-M-1
Copy link

It seems that it still isn't implemented.
How to stop current connection attempt?

According to Pusher.java:


    public void disconnect() {
        if (connection.getState() == ConnectionState.CONNECTED) {
            connection.disconnect();
        }
    }

Moreover, according to WebSocketConnection.java:

    @Override
    public void disconnect() {
        factory.queueOnEventThread(new Runnable() {
            @Override
            public void run() {
                if (state == ConnectionState.CONNECTED) {
                    updateState(ConnectionState.DISCONNECTING);
                    underlyingConnection.close();
                }
            }
        });
    }

So basically there's a lack of opportunities to stop connection when conenctionState is other than ConnectionState.CONNECTED.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants