问题描述
我正在开发CC2650 sensortag和Bluemix(使用IOT入门样板)作为云解决方案.cc2650 android应用程序使用MqttAndroidClient连接到bluemix提供的MQTT服务器.一段时间(大约7分钟)后,我面临的问题是超时.
I am working on CC2650 sensortag and Bluemix(using IOT starter boilerplate) as a cloud solution.The cc2650 android app uses MqttAndroidClient to connect to MQTT server provided by bluemix. The problem I am facing after sometime (around 7 mins) it get timedout.
以下异常在android studio控制台上可见 d:2f7tpk:ti-sensortag2:B0B448C07886:由于没有活动而超时,keepAlive = 240,000 lastOutboundActivity = 1,463,309,545,312 lastInboundActivity = 1,463,309,275,609时间= 1,463,309,785,352 lastPing = 1,463,309,545,312
Following exception is visible on the android studio consoled:2f7tpk:ti-sensortag2:B0B448C07886: Timed out as no activity, keepAlive=240,000 lastOutboundActivity=1,463,309,545,312 lastInboundActivity=1,463,309,275,609 time=1,463,309,785,352 lastPing=1,463,309,545,312
请注意,每10秒钟我会将数据从我的android客户端应用发布到服务器.所以不确定为什么它说没有活动.保持活动间隔设置为120秒.
Please note that every 10 seconds I am publishing the data to server from my android client app. So not sure why it is saying no activity.Keepalive interval is set to 120 seconds.
我确认了.大约7分钟后,正是IBM Bluemix断开了与客户端的连接.在此期间,客户端以10秒的间隔连续发送数据,这在Bluemix设备页面上也可见.
I confirmed it. It is IBM Bluemix which is disconnecting the client after approx 7 min. During this period client was continuously sending the data in 10 sec interval and that was also visible on the Bluemix device page.
任何想法都说明Bluemix为什么在6-7分钟后断开连接(它不是固定的,但有五分之六的连接在7分钟内(大约6分钟后)断开连接.
Any idea why Bluemix is disconnecting it after 6-7 minutes (It is not fixed but out of 6 in 5 it got disconnected in 7 min and once it was around 6 min).
新观察结果:另一个观察结果是,一旦断开连接,则需要10到12次重试,然后我才能重新连接到Bluemix服务器.从Mqttv3客户端,我得到异常无法连接到服务器".但是在此期间,我可以通过cmdline ping实用程序ping服务器.
New observation:The other observation is once it is disconnected then it takes 10-12 retries before I am able to reconnect to Bluemix server. From Mqttv3 client I get the exception "Unable to connect to server". But during this period I am able to ping to server through cmdline ping utility.
推荐答案
这是因为电话cpu处于睡眠模式. http://dalelane.co.uk/blog/?p=1599 解释如下详细说明在Android MQTT客户端中应采取的所有措施.
It was because phone cpu was going in sleep mode.http://dalelane.co.uk/blog/?p=1599 explains in detail what all should be taken care in Android MQTT client.
这篇关于一段时间后,IBM Bluemix断开与MqttAndroidClient的连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!