Comments (10)
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.
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.
You are right, and yes, any support is welcome.
from erlzk.
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.
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.
doh! I'll have a think about them ;-)
from erlzk.
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.
Pull request created - let me know how it looks to you. thanks - K
from erlzk.
from erlzk.
Thanks for your work, and sorry for taking so long.
from erlzk.
Related Issues (10)
- zookeeper create2 test fail HOT 3
- Not able to connect a consul zk address through vpn HOT 2
- Whats the syntax for :erlzk.multi method, if used in Elixir. HOT 1
- When all ZK Servers fail to resolve, erlzk becomes stuck in a loop HOT 6
- Help wanted, kevinbombadil
- FORMAT ERROR after retry HOT 1
- Tag 0.3.1 HOT 1
- Error levels seem too high HOT 5
- erlang:now is deprecated in Erlang 18 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from erlzk.