Giter VIP home page Giter VIP logo

Comments (10)

megayu avatar megayu commented on June 12, 2024

https://github.com/huaban/erlzk/blob/master/src/erlzk_conn.erl#L203

I'm using the same logical like official java client did.

from erlzk.

kevinbombadil avatar kevinbombadil commented on June 12, 2024

I missed that bit - and the way handle-call timeouts are used to trigger the operation..

But still, if there are no messages coming back from the server nothing will happen. So in my test (where I don't drop the server, but just drop the packets) it won't reconnect.

I think this bit in ClientCnxn.java is what is missing :

     if (to <= 0) {
         throw new SessionTimeoutException(
                 "Client session timed out, have not heard from server in "
                         + clientCnxnSocket.getIdleRecv() + "ms"
                         + " for sessionid 0x"
                         + Long.toHexString(sessionId));
     }

.. this depends on a 'lastheard' timestamp which is updated every time something is received from the server - see calls to 'updateLastheard' in clientCnxnSocketNIO.doIO.

One way to do this could be to have a separate process (maybe an fsm) that acts as a timer which gets reset every time something is received from the server. If its not reset in time it can send a message back to erlzk_conn telling it to reconnect.

it would then do the same thing as this bit of code in erlzk_conn:

handle_info({tcp_closed, _Port}, State=#state{host=Host, port=Port, monitor=Monitor}) ->
    error_logger:error_msg("Connection to ~p:~p is broken, reconnect now~n", [Host, Port]),
    notify_monitor_server_state(Monitor, disconnected, Host, Port),

Anyway - please let me know if you think I've missed something. I can try and get this bit working and send the change back if you'd like.. thanks k

from erlzk.

megayu avatar megayu commented on June 12, 2024

You are right, and yes, any support is welcome.

from erlzk.

kevinbombadil avatar kevinbombadil commented on June 12, 2024

Cool. I'll get back to this over the next couple of weeks. I'd also like to implement KillSession - which I could do on a separate fork - I've developed a work-around for it in the meantime but it would be nice for it to be part of erlzk.
https://curator.apache.org/apidocs/org/apache/curator/test/KillSession.html

from erlzk.

megayu avatar megayu commented on June 12, 2024

Actually i just found this feature on my todo list of this project, close session then reconnect a new one if there is no package received from server in 2 / 3 * timeout.

And there are more on my list.

  • readonly connection
  • persistent watcher (after receive watched event just register a new watcher immediately)
  • high-level api, like delete_all, create_all (like mkdir -p)
  • recipe

from erlzk.

kevinbombadil avatar kevinbombadil commented on June 12, 2024

doh! I'll have a think about them ;-)

from erlzk.

kevinbombadil avatar kevinbombadil commented on June 12, 2024

Hi megayu - I have combined the two changes - KillSession and the heartbeat watcher - into my fork - allow a little more time for testing and I'll make a pull request for it soon. Thanks - k

from erlzk.

kevinbombadil avatar kevinbombadil commented on June 12, 2024

Pull request created - let me know how it looks to you. thanks - K

from erlzk.

zugolosian avatar zugolosian commented on June 12, 2024

#8

from erlzk.

megayu avatar megayu commented on June 12, 2024

Thanks for your work, and sorry for taking so long.

from erlzk.

Related Issues (10)

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.