fanliang11 / surging

Surging is a micro-service engine that provides a lightweight, high-performance, modular RPC request pipeline. support Event-based Asynchronous Pattern and reactive programming ,The service engine supports http, TCP, WS,Grpc, Thrift,Mqtt, UDP, and DNS protocols. It uses ZooKeeper and Consul as a registry, and integrates it. Hash, random, polling, Fair Polling as a load balancing algorithm, built-in service governance to ensure reliable RPC communication, the engine contains Diagnostic, link tracking for protocol and middleware calls, and integration SkyWalking Distributed APM
MIT License
3.24k stars 924 forks source link

请问使用Surging MQTT协议做离线消息推送是否可行? #231

Closed wlhappy01 closed 5 years ago

wlhappy01 commented 5 years ago

请问使用Surging MQTT协议做离线消息推送是否可行?

fanliang11 commented 5 years ago

可以通过网关publish willmessage,里面的WillRetain的是是否保留遗嘱消息(也就是订阅相关的topic,发送相关的离线消息),QOS=0 是 清除基于topic 的遗嘱消息,QOS>0是保留以前的遗嘱消息,并且添加到遗嘱消息列表中,然后设备订阅topic后,会send 遗嘱消息,具体操作看下图 default

wlhappy01 commented 5 years ago

感谢! 1.首先测试发现Qos仅仅能设置为0,设置为1或2则返回 { "IsSucceed": false, "Message": "Exception of type 'DotNetty.Codecs.EncoderException' was thrown.|InnerException:Object reference not set to an instance of an object.", "StatusCode": 400 }

2.其次,如果Client处于连接状态是可以收到的;但在WillRetain=true的情况下,客户端离线后发布Topic信息,客户端再次连接还是不能接受到离线之前的消息 {"deviceId":"",

"message":{ "Topic":"/T", "Message":"fff", "Qos":0, "WillRetain":true } } 3.使用MQnetclient客户端测试,将发布消息的retain设置为true,发布消息Surging服务端出错 public MqttApplicationMessage(string topic, byte[] payload, MqttQualityOfServiceLevel qualityOfServiceLevel, bool retain); var appMsg = new MqttApplicationMessage(topic, Encoding.UTF8.GetBytes(inputString), MqttQualityOfServiceLevel.AtMostOnce, true); image image image

以上,辛苦了~!感谢

fanliang11 commented 5 years ago

我先看下,如果感兴趣,可以fix bug

fanliang11 commented 5 years ago

WillRetain=True 可以收到你再试试,Qos>0报错我再看看

wlhappy01 commented 5 years ago

WillRetain=True 可以收到你再试试,Qos>0报错我再看看

我测试还是不能收到离线消息,不知是不是我的流程不对 我的流程是 1.客户端先连接broker,然后publish发送一次消息,此时客户端能接受到消息 image 2.退出客户端,再publish发送一条消息 image 3.客户端再用同样的userid和topic连接broker,看是否收到消息,结果未收到 image

fanliang11 commented 5 years ago

aw4c9ak9fap6lafh uoorwi g32pz6y 9 8 2 4 64 b h 为了不影响他人,你的issues 会进行close ,你的其它的问题,会进行检查,谢谢!