我们先在localhost测试nodejs代码。功能就是把post的json保存到leancloud,没有其他逻辑。
json数据5.9K
ls -lh vnstat.json
-rw-r--r-- 1 charleswang staff 5.9K Aug 6 08:02 vnstat.json
在本地用curl发送数据可以通过,登录leancloud.cn控制台可以看到数据。
curl -v -H "content-type:application/json" localhost:3000/vnstat -d @vnstat.json
* Hostname was NOT found in DNS cache
* Trying ::1...
* Connected to localhost (::1) port 3000 (#0)
POST /vnstat HTTP/1.1
User-Agent: curl/7.37.1
Host: localhost:3000
Accept: /
content-type:application/json
Content-Length: 6002
Expect: 100-continue
< HTTP/1.1 100 Continue
< HTTP/1.1 200 OK
< X-Powered-By: Express
< Date: Thu, 06 Aug 2015 00:05:52 GMT
< Connection: keep-alive
< Transfer-Encoding: chunked
<
* Connection #0 to host localhost left intact
随后用avoscloud deploy后测试,无法发送数据,报错502 bad gateway。