Comments (11)
from coolpy7.
请把你在使用的客户端库告诉我,我去复现一下。
from coolpy7.
我用的是
github.com/eclipse/paho.mqtt.golang
谢谢
from coolpy7.
from coolpy7.
是的,没有特殊的环境的
from coolpy7.
from coolpy7.
请参考这个订阅示例:https://github.com/Coolpy7/coolpy7_benchmark/blob/master/clients_samples/paho_golang_sub_client.go
这里有两点需要说明:1.SetDefaultPublishHandler里的处理代码必须没有阻塞,需要现在这样的代码去处理接收处理逻辑。2.如果网络环境极为不稳定,可以把我注释掉的自动重连功能开启,再把clear session设置为false.
from coolpy7.
谢谢,马上试下
from coolpy7.
按上面的例子已经理好,谢谢
from coolpy7.
from coolpy7.
还有一个问题需要注意,不然的话很可能会把系统的cpu用尽,原因是for goruntine时没有没有做时间中断,所以cpu会一直占用很高,解决办法是增加for的time.sleep,代码如下:
for {
select {
case incoming := <-d.Choke:
//d.mqttHandler(incoming.Client, incoming.Message)
case <-d.Quit:
return
default:
time.Sleep(20*time.Millisecond) //必须增加此句代码让for行业适当的中断时间,cpu才能合理释放。
}
}
from coolpy7.
Related Issues (17)
- unable to start HOT 3
- 客户端定期掉线 HOT 2
- websocket 连接慢 HOT 5
- 测试的时候go_build_Coolpy7_ws_go_linux,出现runtime error: invalid memory address or nil pointer dereference HOT 1
- 启动主程序,提示找不到ip地址,求解决方法 HOT 2
- qq群的图片看不到了? HOT 1
- WEB后台按F5刷新会出现404
- 客户端如何删除
- qos为1或者2的消息没有被持久化保存 HOT 6
- Coolpy7 kernel extension issue HOT 14
- 感谢大家对Coolpy7的支持
- 开源吗? HOT 1
- 组播功能无效 HOT 7
- 是个好项目! HOT 1
- 支持共享主题嘛 HOT 2
- 如何启用帐号密码认证 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coolpy7.