.Net C#的web服务

添加Api.ashx文件
ProcessRequest中只留WebApi.Exec();
添加App_Code文件夹
建立WebApi类,引用Newtonsoft.Json.dll
添加Exec方法
HttpContext context = HttpContext.Current;
获取Post的信息
Stream stream = context.Request.InputStream;
StreamReader streamReader = new StreamReader(stream);
string post = streamReader.ReadToEnd();
转换为json
JObject ji = (JObject)JsonConvert.DeserializeObject(post);
获取Get的信息
string x = context.Request["x"]..ToString();
构造输出json
JObject jo = new JObject();
jo.Add("msg", "hello");
添加执行时间,开始部分
DateTime dt = DateTime.Now;
结束前
TimeSpan ts = DateTime.Now - dt;
jo.Add("cost", ts.TotalSeconds.ToString() + "s");
输出信息
string json = jo.ToString(Formatting.Indented);
context.Response.ContentType = "application/json; charset=utf-8";
context.Response.Write(json);
Api.ashx设为起始页运行之

Linux下软件环境安装(8)-MQTT Mosquitto安装与配置

装在docker里ubuntu 18.04.2
docker run -ti -h mqtt -p 8882:22 -p 8883:1883 --name mqtt withsshd
apt-get install software-properties-common
apt-add-repository ppa:mosquitto-dev/mosquitto-ppa
apt-get update
apt-get install mosquitto mosquitto-clients
service mosquitto status
service mosquitto start
这样就OK了!

离线NTP-Client

sudo ls /var/cache/apt/archives/
如果有deb执行
sudo rm -rf /var/cache/apt/archives/.deb
测试
ntpdate ntp.ubuntu.com
没有,执行
sudo apt-get -d install ntpdate
然后
mkdir ntpdate
sudo mv /var/cache/apt/archives/
.deb ntpdate/
sudo dpkg -i ntpdate/ntpdate_1%3a4.2.8p4+dfsg-3ubuntu5.9_amd64.deb
然后
sudo ntpdate ntp.ubuntu.com
搞定!

Ubuntu多IP

sudo vi /etc/network/interfaces

auto lan1
iface lan1 inet static
address 192.168.2.2
netmask 255.255.255.0
network 192.168.2.0
broadcast 192.168.2.255
gateway 192.168.2.1
dns-nameservers 192.168.2.1

auto lan1:0
iface lan1:0 inet static
address 192.168.1.2
netmask 255.255.255.0

sudo /etc/init.d/networking restart
ifconfig 没生效
sudo service networking restart
stop: Job failed while stopping
start: Job is already running: networking
还是没生效
直接sudo reboot now!!!

lan1 Link encap:Ethernet HWaddr 40:00:00:03:00:76
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::0000:0000:fe03:0076/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1366 errors:0 dropped:1 overruns:0 frame:0
TX packets:198 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:107322 (107.3 KB) TX bytes:18459 (18.4 KB)

lan1:0 Link encap:Ethernet HWaddr 40:00:00:03:00:76
inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

https://www.cnblogs.com/prettyshuang/p/5553700.html

vue & mqtt

vue init webpack mq
cd mq
npm install
npm run dev

https://blog.csdn.net/M_wolf/article/details/79373348
http://www.tongxinmao.com/txm/webmqtt.php

Paho is not defined?!static中也要放一份

mqttws31.rar