MQTT的Payload(负载的最大值)是多少?

我们在学习使用MQTT协议的时候,有的时候我们需要通过MQTT进行一些二进制的传送,那么请问MQTT进行二进制的传送的时候,最大支持多少个字节?
网上答案五花八门,有说64kb的,有说16kb的,有说256kb,有说256M的,
那么到底是多少呢?
其实答案很简单,就是268435455 bytes(255.99999M,约等于256M),为什么呢?
因为Mosquito的MQTT服务器里面的一个配置文件就是这样说的。

# This option sets the maximum publish payload size that the broker will allow.
# Received messages that exceed this size will not be accepted by the broker.
# The default value is 0, which means that all valid MQTT messages are
# accepted. MQTT imposes a maximum payload size of 268435455 bytes.

已标记关键词 清除标记
如题所说,遇到一个bug W/System.err( 1904): Client is not connected (32104) W/System.err( 1904): at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:27) W/System.err( 1904): at org.eclipse.paho.client.mqttv3.internal.ClientComms.internalSend(ClientComms.java:101) W/System.err( 1904): at org.eclipse.paho.client.mqttv3.internal.ClientComms.sendAndWait(ClientComms.java:111) W/System.err( 1904): at org.eclipse.paho.client.mqttv3.MqttClient.subscribe(MqttClient.java:588) W/System.err( 1904): at org.eclipse.paho.client.mqttv3.MqttClient.subscribe(MqttClient.java:482) W/System.err( 1904): at de.eclipsemagazin.mqtt.push.MQTTService$1.handleMessage(MQTTService.java:45) W/System.err( 1904): at android.os.Handler.dispatchMessage(Handler.java:102) W/System.err( 1904): at android.os.Looper.loop(Looper.java:136) W/System.err( 1904): at android.app.ActivityThread.main(ActivityThread.java:5017) W/System.err( 1904): at java.lang.reflect.Method.invokeNative(Native Method) W/System.err( 1904): at java.lang.reflect.Method.invoke(Method.java:515) W/System.err( 1904): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:788) W/System.err( 1904): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:604) W/System.err( 1904): at dalvik.system.NativeStart.main(Native Method) W/System.err( 1904): Timed out waiting for a response from the server (32000) W/System.err( 1904): at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:27) W/System.err( 1904): at org.eclipse.paho.client.mqttv3.internal.ClientComms.connect(ClientComms.java:162) W/System.err( 1904): at org.eclipse.paho.client.mqttv3.MqttClient.connect(MqttClient.java:339) W/System.err( 1904): at de.eclipsemagazin.mqtt.push.MQTTService$3.run(MQTTService.java:111) W/System.err( 1904): at java.lang.Thread.run(Thread.java:841) D/dalvikvm( 599): GC_CONCURRENT freed 874K, 19% free 4489K/5488K, paused 27ms+5ms, total 84ms
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页