Article source: blog.csdn.net/zhou_junhua…
Recently, the company used the push technology in its development project. Here, the pros and cons of various push technologies are not analyzed. There are a lot of online content.
Since MQTT is a protocol, it naturally has its implementation, and the related client and server implementations can be found at github.com/mqtt/mqtt.g…
- The Android client and server side use Java development, so choose the https://github.com/fusesource/mqtt-client.
- Ios platform is not very familiar, colleagues do, choose: github.com/wssand44/MQ…
- MTK platform for an embedded development platform, using c speech development, therefore chose https://github.com/menudoproblema/libemqtt, because c implementation USES Linux socket voice library, so the implementation if you want to use directly, It can be compiled and run in Linux, but we also need to transplant the socket feature of MTK platform, and finally can be used.
- Browsers use the websocket, so finally chose the js library at http://www.eclipse.org/paho/clients/js/.
Push, the core is to establish a long connection, so there are many ways to establish a connection, can be based on TCP, TLS, WB and so on to establish a long connection, here is ashamed, did not understand here at the beginning, so in the client programming, just foolishly write: TCP ://xxx.xxx.xxx:1883, but do not know what this TCP meaning, is in the study of the web version of MQTT communication, see ws://xxx.xxx.xxx:8080 to understand the meaning of this field, WS I think should be the websocket of the shortened bar. Since there are so many ways to establish connections, it is natural that the implementation of the MQTT server side should support these connection methods. At first, I thought that the implementation of the MQTT server side was mainly to manage connections and topic distribution. In fact, it is far from that simple.
Due at the beginning of the project does not involve the web version of the development, in order to achieve fast (to support TLS need other library compiled to just go together), when installing a mosquitto, only supports the TCP connection, so this time development web link their deployment of MQTT server is not line, Mainly the server does not support websocket connections, but that is not to affect our choice of libraries, test.mosquitto.org/ws.html under this page…
Mosquitos still have to work out how to get Mosquitos to support websocket connections, but they’ll have to be covered later.
About mosquitto configuration, you can refer to this article, I am a successful completion of the compiler installation reference this article: blog.chinaunix.net/uid-2588506… Mosquito.conf configuration file, the user name of the bridge client in the mosquito.conf configuration file must be the name of the mosquito.conf user currently logged in. Since I’m logging in as root, this field should be set to root to start mosquito.conf successfully.
-
# bridge client user name \
-
username root
\