1

我正在使用 7.40.0 Cumulocity Java Client SDK 订阅实时通知。我能够收到通知,但在让客户端运行一段时间后,它似乎停止收听并且我不再能够检索通知。

有没有人遇到过这种情况?

WARN  2017-01-03 08:44:49,727 [CumulocityLongPollingTransport-scheduler-0] com.cumulocity.sdk.client.notification.ConnectionHeartBeatWatcher: canceling the long poll request because of inactivity
DEBUG 2017-01-03 08:44:49,727 [CumulocityLongPollingTransport-scheduler-0] com.cumulocity.sdk.client.notification.MessageExchange: canceling [{clientId=4b11irnlptb55g4rs3hauu1ctjpy, channel=/meta/connect, id=16, connectionType=long-polling}]
DEBUG 2017-01-03 08:44:49,727 [CumulocityLongPollingTransport-scheduler-0] com.cumulocity.sdk.client.notification.MessageExchange: stopping heartbeat watcher [{clientId=4b11irnlptb55g4rs3hauu1ctjpy, channel=/meta/connect, id=16, connectionType=long-polling}]
DEBUG 2017-01-03 08:44:50,728 [pool-21-thread-1] com.cumulocity.sdk.client.notification.CumulocityLongPollingTransport.1365985548: sending messages [{clientId=4b11irnlptb55g4rs3hauu1ctjpy, advice={timeout=0}, channel=/meta/connect, id=19, connectionType=long-polling}] 
DEBUG 2017-01-03 08:44:50,728 [pool-21-thread-1] com.cumulocity.sdk.client.notification.MessageExchange: starting heartbeat watcher [{clientId=4b11irnlptb55g4rs3hauu1ctjpy, advice={timeout=0}, channel=/meta/connect, id=19, connectionType=long-polling}]
DEBUG 2017-01-03 08:44:51,710 [CumulocityLongPollingTransport-scheduler-1] com.cumulocity.sdk.client.notification.MessageExchange: wait for response headers [{clientId=4b11irnlptb55g4rs3hauu1ctjpy, advice={timeout=0}, channel=/meta/connect, id=19, connectionType=long-polling}]
DEBUG 2017-01-03 08:44:51,710 [CumulocityLongPollingTransport-scheduler-1] com.cumulocity.sdk.client.notification.MessageExchange: recived response headers [{clientId=4b11irnlptb55g4rs3hauu1ctjpy, advice={timeout=0}, channel=/meta/connect, id=19, connectionType=long-polling}] 
DEBUG 2017-01-03 08:44:51,710 [CumulocityLongPollingTransport-scheduler-1] com.cumulocity.sdk.client.notification.MessageExchange: getting heartbeants  POST https://msc.cumulocity.com//cep/realtime returned a response status of 200 OK
DEBUG 2017-01-03 08:44:51,710 [CumulocityLongPollingTransport-scheduler-1] com.cumulocity.sdk.client.notification.MessageExchange: new messages recived
DEBUG 2017-01-03 08:44:51,711 [CumulocityLongPollingTransport-scheduler-1] com.cumulocity.sdk.client.notification.MessageExchange: Received messages [{channel=/meta/connect, id=19, advice={reconnect=retry, interval=0, timeout=5400000}, successful=true}]
DEBUG 2017-01-03 08:44:51,711 [CumulocityLongPollingTransport-scheduler-1] com.cumulocity.sdk.client.notification.MessageExchange: stopping heartbeat watcher [{clientId=4b11irnlptb55g4rs3hauu1ctjpy, advice={timeout=0}, channel=/meta/connect, id=19, connectionType=long-polling}]
DEBUG 2017-01-03 08:44:51,711 [pool-21-thread-1] com.cumulocity.sdk.client.notification.CumulocityLongPollingTransport.1365985548: sending messages [{clientId=4b11irnlptb55g4rs3hauu1ctjpy, channel=/meta/connect, id=23, connectionType=long-polling}] 
DEBUG 2017-01-03 08:44:51,711 [pool-21-thread-1] com.cumulocity.sdk.client.notification.MessageExchange: starting heartbeat watcher [{clientId=4b11irnlptb55g4rs3hauu1ctjpy, channel=/meta/connect, id=23, connectionType=long-polling}]
DEBUG 2017-01-03 08:56:51,711 [CumulocityLongPollingTransport-scheduler-0] com.cumulocity.sdk.client.notification.MessageExchange: canceling [{clientId=4b11irnlptb55g4rs3hauu1ctjpy, channel=/meta/connect, id=23, connectionType=long-polling}]
DEBUG 2017-01-03 08:56:51,711 [CumulocityLongPollingTransport-scheduler-0] com.cumulocity.sdk.client.notification.MessageExchange: stopping heartbeat watcher [{clientId=4b11irnlptb55g4rs3hauu1ctjpy, channel=/meta/connect, id=23, connectionType=long-polling}]
DEBUG 2017-01-03 08:56:52,711 [pool-21-thread-1] com.cumulocity.sdk.client.notification.CumulocityLongPollingTransport.1365985548: sending messages [{clientId=4b11irnlptb55g4rs3hauu1ctjpy, advice={timeout=0}, channel=/meta/connect, id=26, connectionType=long-polling}] 
DEBUG 2017-01-03 08:56:52,712 [pool-21-thread-1] com.cumulocity.sdk.client.notification.MessageExchange: starting heartbeat watcher [{clientId=4b11irnlptb55g4rs3hauu1ctjpy, advice={timeout=0}, channel=/meta/connect, id=26, connectionType=long-polling}]
DEBUG 2017-01-03 08:56:53,659 [CumulocityLongPollingTransport-scheduler-0] com.cumulocity.sdk.client.notification.MessageExchange: wait for response headers [{clientId=4b11irnlptb55g4rs3hauu1ctjpy, advice={timeout=0}, channel=/meta/connect, id=26, connectionType=long-polling}]
DEBUG 2017-01-03 08:56:53,659 [CumulocityLongPollingTransport-scheduler-0] com.cumulocity.sdk.client.notification.MessageExchange: recived response headers [{clientId=4b11irnlptb55g4rs3hauu1ctjpy, advice={timeout=0}, channel=/meta/connect, id=26, connectionType=long-polling}] 
DEBUG 2017-01-03 08:56:53,659 [CumulocityLongPollingTransport-scheduler-0] com.cumulocity.sdk.client.notification.MessageExchange: getting heartbeants  POST https://msc.cumulocity.com//cep/realtime returned a response status of 200 OK
DEBUG 2017-01-03 08:56:53,660 [CumulocityLongPollingTransport-scheduler-0] com.cumulocity.sdk.client.notification.MessageExchange: new messages recived
DEBUG 2017-01-03 08:56:53,661 [CumulocityLongPollingTransport-scheduler-0] com.cumulocity.sdk.client.notification.MessageExchange: Received messages [{channel=/meta/connect, id=26, advice={reconnect=retry, interval=0, timeout=5400000}, successful=true}]
DEBUG 2017-01-03 08:56:53,661 [CumulocityLongPollingTransport-scheduler-0] com.cumulocity.sdk.client.notification.MessageExchange: stopping heartbeat watcher [{clientId=4b11irnlptb55g4rs3hauu1ctjpy, advice={timeout=0}, channel=/meta/connect, id=26, connectionType=long-polling}]
DEBUG 2017-01-03 08:56:53,661 [pool-21-thread-1] com.cumulocity.sdk.client.notification.CumulocityLongPollingTransport.1365985548: sending messages [{clientId=4b11irnlptb55g4rs3hauu1ctjpy, channel=/meta/connect, id=28, connectionType=long-polling}] 
DEBUG 2017-01-03 08:56:53,661 [pool-21-thread-1] com.cumulocity.sdk.client.notification.MessageExchange: starting heartbeat watcher [{clientId=4b11irnlptb55g4rs3hauu1ctjpy, channel=/meta/connect, id=28, connectionType=long-polling}]
4

2 回答 2

1

我也有同样的经历。显然,在我们的案例中,一些中间盒在服务器发送 keepalive 数据包之前(默认为 10 分钟后)丢弃了长轮询 TCP 连接。

此外,在使用 7.26 版本的 Java 参考代理进行测试时,我们看到如果代理没有收到服务器端的 keepalive,它会在 3 次尝试后停止重新建立长轮询连接。没有检查这是否在以后的版本中发生了变化。

我们运行我们自己的 Cumulocity 实例,并且能够配置服务器端的保活计时器。我们将 keepalive 计时器设置为 3 分钟,从而解决了这个问题。

于 2017-01-05T12:01:24.800 回答
1

当您拥有配置为丢弃或切断网络流量以实现长期连接的中间网络设备时,可能会发生这种情况。示例是企业 HTTP 代理,但移动网络提供商也可能具有此类配置。

这很难解决,通常你必须通过低级别的wireshark或网络协议手段。我们通过以下机制取得了成功:

  • 使用不同的网络,例如,直接 DSL 线路而不是公司 Intranet。
  • 向您的 IT 或网络提供商提出要求,不要过早切断连接或不丢弃数据包。
  • 如果您自己运行 Cumulocity,您可以将其配置为更频繁地发送服务器端心跳。这使得中间网络设备将连接视为实时连接,但代价是所有客户端的额外流量。
  • 使用 MQTT API 并设置更高的 ping 速率。

抱歉这里没有简单的答案:-)

于 2017-01-04T09:51:55.363 回答