Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to set the kC4ReplicatorHeartbeatInterval in C4ReplicatorParams #49

Open
CedricCouton opened this issue Sep 7, 2020 · 4 comments
Open
Labels
enhancement New feature or request

Comments

@CedricCouton
Copy link

Hi,

I would like to set the heartbeat params to the c4replicatorparams (kC4ReplicatorHeartbeatInterval) how can do it this library ? Perhaps we can have a new_with_options in Replicator ?

Thanks

@Dushistov
Copy link
Owner

I suppose it can be set_option(&mut self, ...). But you should take into consideration
that if you used tokio based network transport that option would be ignored.
It is not implemented yet.

@Dushistov Dushistov added the enhancement New feature or request label Sep 7, 2020
@CedricCouton
Copy link
Author

This option is used by the c4WebSocket no ? In WebSocketImpl.cc lig 116 if (heartbeatInterval() > 0) { _pingTimer.reset(new actor::Timer(bind(&WebSocketImpl::sendPing, this))); schedulePing(); }
So it is independent to tokio (i think), the schedulePing sendBytes throw the factory write function I think. What's your opinion ?

@CedricCouton
Copy link
Author

You are right, the params is only used in the c4 wbesocket impl...
I have to search in tokio side. But in tungstenite the TcpStream is not exposed so it's not possible to call the set_keepalive.

@Dushistov
Copy link
Owner

couchbase-lite (C/C++) part has two alternatives to work with web sockets:

  1. work with raw bytes stream (so couchbase-lite parse data by itself)
  2. work with messages handled by C4SocketFactory

Because of usage of API of tungstenite this crate uses variant (2).

So to handle it in the write way, some extra functional should be added here:

debug!("read loop({:x}): ping", sock_id);

to handle ping/pong messages and
plus it should some kind of finite state machine based on tokio timers to handle missed pong message and inform C/C++ part of this library about problem.

I have plans to implement this, but I was busy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants