简体   繁体   English

Eclipse Milo 在失去连接后没有重新连接到服务器 - 订阅

[英]Eclipse Milo doesn't reconnect to server after lost connection - subscriptions

I am working on subscriptions with Milo and I am trying to make re-connection after connection to server is lost.我正在使用 Milo 进行订阅,我正在尝试在与服务器的连接丢失后重新连接。 I subscribe a few thousands of nodes.我订阅了几千个节点。 I added custom SubscriptionListener and after I break a network I receive calls to onPublishFailure() in my SubscriptionListener where I invoke subscriptionManager.clearSubscriptions() and then I resubscribe the same nodes but nothing happens after that.我添加了自定义SubscriptionListener ,在中断网络后,我在SubscriptionListener中收到对onPublishFailure()的调用,在其中调用subscriptionManager.clearSubscriptions()然后我重新订阅相同的节点,但之后没有任何反应。

What's correct approach to handle a lost connection to server for subscriptions?处理与服务器的订阅丢失连接的正确方法是什么?

The correct approach is mostly to do nothing - all of the details of reconnecting are handled automatically.正确的方法主要是什么都不做——重新连接的所有细节都会自动处理。

The only case you need to handle is when the subscriptions were unable to be transferred after a new session was created.您需要处理的唯一情况是在创建新的 session 后无法转移订阅。 Implement SubscriptionListener#onSubscriptionTransferFailed to re-create any subscription this callback indicates has failed to transfer.实施SubscriptionListener#onSubscriptionTransferFailed以重新创建此回调指示传输失败的任何订阅。

There's not really any other scenario where you should be manually clearing and re-creating your subscriptions.实际上没有任何其他情况应该手动清除和重新创建订阅。 The onPublishFailure() callback is largely informational and does not require action. onPublishFailure()回调主要是信息性的,不需要操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM