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

I cannot send message to MQTT broker #1

Open
SoonyangZhang opened this issue Dec 9, 2016 · 1 comment
Open

I cannot send message to MQTT broker #1

SoonyangZhang opened this issue Dec 9, 2016 · 1 comment

Comments

@SoonyangZhang
Copy link

SoonyangZhang commented Dec 9, 2016

Hi ,Is there something wrong? The is no reaction when I send message data to MQTT broker.But the client did connect to the Broker. It seems there are bugs. The code connect Server in asynchronous way with netty. So when I send message with the method publish(String topic, ByteBuf payload),the parameter of channel is null.

@AYWWWWW
Copy link

AYWWWWW commented May 22, 2017

publish是发布消息,你要接收消息,需要用on来订阅这个topic,其中的参数MqttHandler hanler是一个接口实现,在这个接口实现中写自己的onMessage方法。
/** * Subscribe on the given topic, with the given qos. When a message is received, MqttClient will invoke the {@link MqttHandler#onMessage(String, ByteBuf)} function of the given handler * This subscribtion is only once. If the MqttClient has received 1 message, the subscribtion will be removed * * @param topic The topic filter to subscribe to * @param handler The handler to invoke when we receive a message * @param qos The qos to request to the server * @return A future which will be completed when the server acknowledges our subscribe request */ @Override public Future<Void> once(String topic, MqttHandler handler, MqttQoS qos) { return createSubscribtion(topic, handler, true, qos); }

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

2 participants