ripple-unmaintained / ripple-lib-java

Java version of ripple-lib (work in progress)
ISC License
126 stars 109 forks source link

When socket server restart, onClose callback runs in Infinite loop? #84

Open passionofvc opened 6 years ago

passionofvc commented 6 years ago

hi @sublimator I use ripple-lib-java(com.ripple.client) to connect to rippled daemon server for new validated transaction, when socket server restart rippled, I found onClose callback runs in Infinite loop, and continue to connect and disconnect. Does the disconnect problem fixed?

        <client>                         < WebSocketTransport >                   <WS(WebSocketClient)>
    --->connect(String , OnConnected)
|--> --->connect(final String uri)
|    --->doConnect(String uri) -------- |
|                                       |--->ws.connect(URI.create(uri)); --|
|                                                                           |------>   ws.connect();
|
|                                                                              |----<---  onClose()  when socket server restart, callback here
|                                    |--<---handler.onDisconnected(false); <---|
|    <----onDisconnected(boolean) <--|
| -----<----doOnDisconnected()
sublimator commented 6 years ago

I don't understand what you are trying to say.

Try using the sublimator fork of this lib. I did a bit of work on it recently, fixing some bugs with reconnects and freeing resources.

sublimator commented 6 years ago

See: https://github.com/sublimator/ripple-lib-java

passionofvc commented 6 years ago

thanks @sublimator I will the check out your new repository.

sublimator commented 6 years ago

Also, make sure you are you doing everything from within run(...) blocks or onX(...) handlers, as the API is not thread safe.

passionofvc commented 6 years ago

hi @sublimator I understand all the request and response must be run by ScheduledThreadPoolExecutor's clientThread, thanks!

sublimator commented 6 years ago

Let me know if you have any issues. I did some extra commits since last testing the reconnect stuff.

I haven't had a chance to write any quality automated tests, however last I checked I left the client reconnecting over night with scripted network drops and it held up well with seemingly no blowouts.

Also, be careful with the TransactionManager, it needs some love.