Code Monkey home page Code Monkey logo

Comments (8)

dsrees avatar dsrees commented on July 16, 2024

from javaphoenixclient.

AdamGrzybkowski avatar AdamGrzybkowski commented on July 16, 2024

In my case there is one requirement:
The WS connection has to be open no matter what as long as users did not terminate it by closing the app/screen.

So I do try to reconnect on every error.

from javaphoenixclient.

AdamGrzybkowski avatar AdamGrzybkowski commented on July 16, 2024

@dsrees I went through the code and here is what I found:

  1. I think you are closing the WS with wrong error when the heartbeat times out. Here you should probably pass WS_CLOSE_SOCKET_EXCEPTION if you want to trigger reconnectTimer.
  2. The next problem is in the same line. You are calling this.connection?.disconnect(...) but this basically tries to call .close(...) on the OkHttp Websocket. This does not work because the WS is already closed so no callback will be invoked.

I've been able to reproduce this problem using android emulator and Network Link Conditioner

On a side note. I was a bit confused when I saw this . Don't you think it is strange that this is in a Transport class just to trigger reconnectTimer in the Socket when all of the reconnection logic is in that class. Is there any reason why this is not handled in the Socket?

from javaphoenixclient.

AdamGrzybkowski avatar AdamGrzybkowski commented on July 16, 2024

One more thing. The Socket.reconnectTimer will be scheduled only once. Because it is never scheduled again after its callback is invoked. This could be simply fixed by scheduling it here.
The one thing I'm not sure about is how it will work with the Channel.rejoinTimer. This one is being scheduled properly but if the connection is dropped it won't be able to reestablish the WS connection.
WDYT?

from javaphoenixclient.

dsrees avatar dsrees commented on July 16, 2024

@AdamGrzybkowski Thanks for digging into this! It's appreciated. I'll be able to look into this more this weekend

from javaphoenixclient.

dsrees avatar dsrees commented on July 16, 2024

Made a few changes over the weekend. Need to update the tests to match. Will update when I get closer to fixing these up.

from javaphoenixclient.

dsrees avatar dsrees commented on July 16, 2024

I've resolved the issues regarding the heartbeat timing out and made some changes to the Transport layer to better mimic the JS websocket protocol.

Leaving this issue open since I'll still need to investigate the reconnectTimer only being scheduled once

from javaphoenixclient.

dsrees avatar dsrees commented on July 16, 2024

reconnectTimer will be scheduled each time the connection is closed. Changes will be available in the next release

from javaphoenixclient.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.