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

[streaming] ping related cleanup, inspection cleanup #3533

Merged
merged 5 commits into from
May 25, 2020
Merged

[streaming] ping related cleanup, inspection cleanup #3533

merged 5 commits into from
May 25, 2020

Conversation

earce
Copy link
Collaborator

@earce earce commented May 23, 2020

Cleaning up some redundant parts of the code related to ping.

Log + Gemini both override method protected void handleIdle(ChannelHandlerContext ctx) which is now part of NettyStreamingService.java behavior so have removed these overrides. Since Gemini's idle time was 15 seconds which is Netty's default --have switched to use that default var.

In my QA environment I saw bitrich-info/xchange-stream#502 present itself and pingStatus treated as an unknown message type which I have now added to the switch to log as a warn given this presents itself when we are hitting rate limits. Not sure if another log level makes more sense? Additionally, is this issue only a product of attempting to open many WebSocket connections quickly, or can it occur by hammering a single WebSocket channel with 15+ subscriptions?

Have removed protected Completable openConnection() override from KrakenStreamingService.java given that the idle ping sends a ping out every 15 seconds of being idle (this will now be a web socket ping rather then an application level ping). @mdvx I saw you had added this in, with what frequency were you seeing disconnects? Was the heartbeat not sufficient to keep the connection alive?

In NettyStreamingService.java have cleared up some inspection warnings.

@mdvx
Copy link
Contributor

mdvx commented May 24, 2020

@earce In my case, I can't tolerate the connection going down, and simply reconnecting, as I may miss updates, I need to clear my caches as soon as this is detected (and rebuild them after a fresh connect).

There are a couple PR from the old project I still need to bring over for this (I can only do one at a time)

@earce
Copy link
Collaborator Author

earce commented May 24, 2020

@mdvx I ran several tests with the iteration of the code in this review and never saw a disconnect.

Are the PRs you are referring to related to the issues with Kraken connectivity?

@mdvx
Copy link
Contributor

mdvx commented May 24, 2020

No, not Kraken Specifically (but I can;t remember what prompted the changes). I have migrated them to this new PR now #3534

@badgerwithagun
Copy link
Collaborator

@mdvx are you comfortable with these changes, as they overlap with yours?

Are you aware that there is no way to either ensure the connection stays up or to detect if it drops 100% reliably? It's just not a feature of TCP.

I'm currently working on a background PR to add something I use in my app to the library: a wrapper for Exchange that adds backup polling when streaming and combines the two into a single stream. It's the best way I've found of resyncing streams when there are undetected lost frames. If you're interested I can put up a work-in-progress PR.

@@ -57,6 +54,9 @@ protected void handleMessage(JsonNode message) {
KrakenEventType krakenEvent;
if (event != null && (krakenEvent = KrakenEventType.getEvent(event.textValue())) != null) {
switch (krakenEvent) {
case pingStatus:
LOG.warn("PingStatus received: {}", message);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warn is quite high. Does this warrant waking someone up for?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to info

@@ -163,8 +163,7 @@ protected Completable openConnection() {
if (ssl) {
SslContextBuilder sslContextBuilder = SslContextBuilder.forClient();
if (acceptAllCertificates) {
sslContextBuilder =
sslContextBuilder.trustManager(InsecureTrustManagerFactory.INSTANCE);
sslContextBuilder.trustManager(InsecureTrustManagerFactory.INSTANCE);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like the fmt plugin needs rerunning here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reran (nothing changed here but gemini streaming service did)

Copy link
Collaborator

@badgerwithagun badgerwithagun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a couple of questions/spots

@earce
Copy link
Collaborator Author

earce commented May 24, 2020

@badgerwithagun yes typically with failed writes and timeouts, and this can be tougher to do depending on why the socket connection was broken.

Yes I'd be curious to see how you are combining polling and streaming. To your point of resyncing streams, are do you mean adding in polling to reconcile missed data or something else all together?

Yes I would be curious to see this PR.

@mdvx let me know if there is anything with this review that you need changed.

Also tangential but I know probably due to the ongoing crisis affecting every one the cadence of these releases has changed but does the project have an idea when 5.0.0 may be cut?

@mdvx
Copy link
Contributor

mdvx commented May 24, 2020

@mdvx I saw you had added this in, with what frequency were you seeing disconnects? Was the heartbeat not sufficient to keep the connection alive?

It was disconnecting within the minute, every minute.

@earce
Copy link
Collaborator Author

earce commented May 24, 2020

@mdvx I saw you had added this in, with what frequency were you seeing disconnects? Was the heartbeat not sufficient to keep the connection alive?

It was disconnecting within the minute, every minute.

I didn't see any disconnects after running with this implementation for some time.

@mdvx
Copy link
Contributor

mdvx commented May 24, 2020

We are all a bit out of sync, when I added the onIdle ctx write ping frame, the pingStatus message did not exist, it is possible we are doubling up now. I am installing the PR as it stands, with my other PRs and checking Gemini works

@mdvx
Copy link
Contributor

mdvx commented May 24, 2020

I see no problems with this implementation :-) @earce @badgerwithagun

@mdvx
Copy link
Contributor

mdvx commented May 24, 2020

Right now, I can't implement

class GeminiStreamingExchange { @Override public Observable<Throwable> reconnectFailure() { return streamingService.subscribeReconnectFailure(); } @Override public Observable<Object> connectionSuccess() { return streamingService.subscribeConnectionSuccess(); } }

because Gemini is using
private Map<CurrencyPair, GeminiProductStreamingService> productStreamingServices;

instead of a single GeminiProductStreamingService

any thoughts?

@badgerwithagun
Copy link
Collaborator

I'm merging this for now. Can we move your question to a separate issue, please, @mdvx?

I do think the info level logging for pingStatus is a bit excessive, but happy to leave that for now for Kraken users to debate over.

@badgerwithagun badgerwithagun merged commit f78f9cf into knowm:develop May 25, 2020
@mdvx
Copy link
Contributor

mdvx commented May 25, 2020

#3537

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

Successfully merging this pull request may close these issues.

3 participants