我无法使用JSON从Node-RED连接到Freeboard.io [英] I can`t connect from Node-RED to Freeboard.io using JSON
问题描述
我试图创建一个干舷仪表板.我有一个带有四个传感器的Arduino,它们通过mqtt发送其信息.因此,我在Node-RED上生成了一个JSON以响应/saida中的get请求.
I trying to create a freeboard dashboard. I have a Arduino with four sensors that send their informations by mqtt. So, I on Node-RED I gen a JSON to response get request in /saida.
[{"id":"3f699b5.c91f064","type":"http response","z":"c7d4e8c8.509218","name":"","x":1184,"y":589,"wires":[]},{"id":"a3ed6250.1d64","type":"json","z":"c7d4e8c8.509218","name":"","x":1120.5,"y":540,"wires":[["3f699b5.c91f064"]]},{"id":"971f41c1.a1265","type":"function","z":"c7d4e8c8.509218","name":"","func":"msg.payload = {\"temperatura\":\"25\"}\nreturn msg;","outputs":1,"noerr":0,"x":1015.5,"y":584,"wires":[["a3ed6250.1d64"]]},{"id":"ed9f7a2a.604728","type":"http in","z":"c7d4e8c8.509218","name":"http in","url":"/saida","method":"get","swaggerDoc":"","x":850,"y":582,"wires":[["5b40d38c.5cc7ec","971f41c1.a1265"]]}]
此刻,我正在使用静态JSON进行测试.我有一个像这样的主机:
In this moment, I`m using a static JSON to make a test. I have a use the host like:
my-public-host:1880/saida -> {"temperatura":"25"}
我通过代理访问它,JSON返回OK.在ping.eu端口检查中,端口已打开.我确保我的房东是公开的.
I access it by a proxy, the JSON returns ok. On ping.eu port check, the port is open. I ensure that my host is public.
但是在我的干舷上,我将其添加为数据源,然后说从不"更新,因此我无法读取JSON信息.
But on my freeboard, I add it as datasource, then it says "never" update and I can`t read the JSON info.
我应该怎么解决?
推荐答案
我解决了我的问题.
freeboard.io中存在错误. somethingproxy.freeboard.io无法正常工作.浏览器不允许freeboard.io向非https的其他链接发出AJAX请求.此外,浏览器不允许对其他主机发出AJAX请求.
There is a bug in freeboard.io. the thingproxy.freeboard.io don't work. The the browser don't let the freeboard.io make AJAX request for other link that isn't https. Besides, the browser don't let make a AJAX request for an other host.
有两种解决方案:
- 在主机上使用站点锁,然后将Access-Control-Allow-Origin添加到响应标头中.
- 使用https代理和浏览器扩展程序允许交叉访问.
再见!
这篇关于我无法使用JSON从Node-RED连接到Freeboard.io的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!