Giter VIP home page Giter VIP logo

paho.mqtt.wxapp's Introduction

使用方法

git clone https://github.com/tennessine/paho.mqtt.wxapp.git

执行mvn后会在target下生成paho-mqtt.js、paho-mqtt.min.js,然后在微信小程序里引入即可

直接下载

https://unpkg.com/[email protected]/target/paho-mqtt-min.js

https://unpkg.com/[email protected]/target/paho-mqtt.js

通过npm安装

npm install --save paho-wxapp

sample目录是我写的一个小程序连接MQTT broker的demo

在线文档

https://tennessine.github.io/paho.mqtt.wxapp/target/docs/

百度云测试服务器

host:miniprogram.mqtt.iot.bj.baidubce.com

port:443

username:miniprogram/gekongfei

password:sgx+vSWVMhLS5asUlvXZG03vDTGO8McG+9IMwbVpL40=

注意事项

小程序只能用备案后的域名,并且不能带端口号,所以如果你服务器不是用的443端口或者用的是第三方的服务器,那就需要用nginx反向代理一下(百度云物接入已经支持443端口,无需代理)。

nginx反向代理

server {
  listen 443;
  server_name www.mengmeitong.com;
  ssl on;
  root /opt/nginx/wwwroot/laravel/public;
  index index.php index.html index.htm;
  ssl_certificate   cert/www.mengmeitong.com.crt;
  ssl_certificate_key  cert/www.mengmeitong.com.key;
  ssl_session_timeout 5m;
  ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_prefer_server_ciphers on;

  location = /mqtt {
    proxy_pass https://miniprogram.mqtt.yourserver.com:8884;
    proxy_redirect off;
    proxy_set_header Host https://miniprogram.mqtt.yourserver.com:8884;

    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
  }
}

QQ群

679985050 (2k)

paho.mqtt.wxapp's People

Contributors

tennessine avatar visoar avatar

Watchers

 avatar  avatar

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.