Code Monkey home page Code Monkey logo

Comments (11)

jacoblai avatar jacoblai commented on August 23, 2024

from coolpy7.

jacoblai avatar jacoblai commented on August 23, 2024

请把你在使用的客户端库告诉我,我去复现一下。

from coolpy7.

soitun avatar soitun commented on August 23, 2024

我用的是
github.com/eclipse/paho.mqtt.golang
谢谢

from coolpy7.

jacoblai avatar jacoblai commented on August 23, 2024

from coolpy7.

soitun avatar soitun commented on August 23, 2024

是的,没有特殊的环境的

from coolpy7.

jacoblai avatar jacoblai commented on August 23, 2024

from coolpy7.

jacoblai avatar jacoblai commented on August 23, 2024

请参考这个订阅示例:https://github.com/Coolpy7/coolpy7_benchmark/blob/master/clients_samples/paho_golang_sub_client.go
这里有两点需要说明:1.SetDefaultPublishHandler里的处理代码必须没有阻塞,需要现在这样的代码去处理接收处理逻辑。2.如果网络环境极为不稳定,可以把我注释掉的自动重连功能开启,再把clear session设置为false.

from coolpy7.

soitun avatar soitun commented on August 23, 2024

谢谢,马上试下

from coolpy7.

soitun avatar soitun commented on August 23, 2024

按上面的例子已经理好,谢谢

from coolpy7.

jacoblai avatar jacoblai commented on August 23, 2024

from coolpy7.

jacoblai avatar jacoblai commented on August 23, 2024

还有一个问题需要注意,不然的话很可能会把系统的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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.