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

mqtt client存在的三个问题 #564

Closed
jackeyt opened this issue Jun 1, 2024 · 0 comments
Closed

mqtt client存在的三个问题 #564

jackeyt opened this issue Jun 1, 2024 · 0 comments

Comments

@jackeyt
Copy link

jackeyt commented Jun 1, 2024

目前Libhv中的mqtt client在使用过程存在三个问题:

  • 1、mqtt login没有超时机制,在mqtt_client_connect的时候,有设置一个hio_connect的超时定时器:
 if (cli->connect_timeout > 0) {
       hio_set_connect_timeout(io, cli->connect_timeout);
   }

但是login没有,假如在hio_connet成功之后,就会关闭connect超时定时器,但是万一此时tcp链路断了,Login不成功,是没有办法有时间限制login的时长,然后去断开重连再login的。
问一下博主,是推荐在Login函数内部去加定时器呢?还是在外部,启动login的时候,加个htimer去判断cli->connected值呢?

  • 2、没有发送失败重连机制:假如mqtt conn成功了,然后ping周期设得比较长,比如说1分钟,但是publish报文到server端的周期比较快,比如是几秒或10几秒种,但是此时mqtt是断开的(!connected,return -2),那么是会返回-2,这种情况也没有触发重连;或者第二种情况如果ping fail的次数还没有到三次,connected还是=1,但是此时tcp链路已经断了,发送时nwrite会返回长度,事实上并没有发送出去给server,这种情况也没有触发重连

  • 3、mqtt client在连接服务器时,hio_connect会莫名奇妙的coredump,相同的代码运行几百次可能会出现一次,出错时的堆栈信息如下:(屏蔽了一些用户信息哈)
    0602003157

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

No branches or pull requests

1 participant