Skip to content

Enable and Disable ping/pong #699

Closed
Closed

Description

@anishlg

Expected Behavior

The ping/pong is enabled to identify the lost connection. For connection to work properly in Android mobile sleep mode, we should be able to disable ping/pong in sleep mode and enable it back again when device wakes up.

Current Behavior

In Android mobile goes to sleep mode, when we disable ping/pong using setConnectionLostTimeout(0). It works fine. But when we enable ping/pong (when device wakes up) using setConnectionLostTimeout(30), it does not work. When we checked, we find that the timer is destroyed on setConnectionLostTimeout(0). We expect it to be created and set on setConnectionLostTimeout(30). But it does not happen. Because of this, we don't have any method of enabling ping/pong once it is disabled.

Expected Solution

Currently disabling the ping/pong by setConnectionLostTimeout(0) is working. Library has to make the necessary changes to ensure ping/pong is enabled back when setConnectionLostTimeout(30) is called.
(or) If Library adds 2 separate methods to enable and disable ping/pong, that will be even better.
.

Steps to Reproduce (for bugs)

  1. Use the lib to create the android client app
  2. Connect with websocket server.
  3. Enable ping/pong in android app
  4. Set setConnectionLostTimeout(0) in android device sleep mode
  5. Set setConnectionLostTimeout(30) when android device waked up
  6. Put android device in sleep mode - the ping/pong disabled due to setConnectionLostTimeout(0)
  7. Put android in normal mode - the ping/pong didn't enabled event after setConnectionLostTimeout(30). From debug identified the timer is already destroyed.

Debug log (for bugs)

Context

Your Environment

  • Java-WebSocket:1.3.7
  • Java version: 1.8
  • Operating System and version: Android 8.1
  • Endpoint Name and version:
  • Link to your project:

Activity

  1. marci4 commented on Apr 26, 2018

    @marci4
    Collaborator

    Hello @anishlg,

    thank you very much for opening this issue!

    What do you think is the better approach? I am in favour of adding the possibility to reactivate the lost connection detection with the setter rather then adding an additional method.

    Could you also provide a simple application for me since I haven't done any android app.

    Thank you very much!

    Best regards,
    marci4

  2. anishlg commented on May 3, 2018

    @anishlg
    Author

    @marci4 ,
    We create an android sample app for the issue testing. Please use this attached apk and connect to any webSocket server with ping/pong.
    Instructions are provided in the attached ppt. Follow the same to reproduce the issue and please let us know any further queries...

    android.zip

    Best regards,
    Anish

  3. Adezking commented on May 8, 2018

    @Adezking

    Hello @anish,
    I don't know much about programming and I've been finding it difficult to build my own Binary.com webSocket API connection system.
    Pls I'll be willing to pay for your service if you can help me build for PC and mobile.My email is..

    Adezking2007@gmail.com

    THANKS.

  4. anishlg commented on May 11, 2018

    @anishlg
    Author

    @marci4 ,
    Any update on this issue. we already shared the android app which can reproduce the issue. please revert with your suggestions for the same. If any clarification required, please let me know

    Regards,
    Anish

  5. marci4 commented on May 11, 2018

    @marci4
    Collaborator

    Hello @anishlg,
    Sorry for not responding to use. Right now I am very busy and forgot to answer you.

    I wrote the code and did not have this use case in mind (since this library is designed for java in the first place).
    I just asked for the code to get a better understanding what is the best approach.
    Never the less I cannot promise that I can integrate this feature soon since I am busy right now with a lot of work.

    Best regards,
    marci4

  6. added a commit that references this issue on May 14, 2018
  7. marci4 commented on May 14, 2018

    @marci4
    Collaborator

    Hello @anishlg,
    this issue should be solved with #708.

    Could you maybe try it out?
    Thank you!

    Best regards,
    marci4

  8. self-assigned this
    on May 14, 2018
  9. added this to the Release 1.3.9 milestone on May 14, 2018
  10. Gillardo commented on Jun 10, 2018

    @Gillardo

    Any idea when this will be available?

  11. marci4 commented on Jul 6, 2018

    @marci4
    Collaborator

    This issue is already in the master!

    Closing it!

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

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions