Thingsboard I/O 请求 POST 错误

Thingsboard I/O error on POST request

我正在尝试创建一个插件,post将从设备接收的数据发送到另一个应用程序。但是,我没有看到任何数据进入我的应用程序。当我查看插件的错误事件时,我看到以下堆栈跟踪:

org.thingsboard.server.extensions.api.rules.RuleException: I/O error on POST request for "http://127.0.0.1:7890/stream/gps":
Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)
at org.thingsboard.server.extensions.rest.plugin.RestApiCallMsgHandler.process(RestApiCallMsgHandler.java:64)
at org.thingsboard.server.extensions.api.plugins.AbstractPlugin.process(AbstractPlugin.java:47)
at org.thingsboard.server.actors.plugin.PluginActorMessageProcessor.onRuleToPluginMsg(PluginActorMessageProcessor.java:101)
at org.thingsboard.server.actors.plugin.PluginActor.onRuleToPluginMsg(PluginActor.java:93)
at org.thingsboard.server.actors.plugin.PluginActor.onReceive(PluginActor.java:52)
at akka.actor.UntypedActor$$anonfun$receive.applyOrElse(UntypedActor.scala:167)
at akka.actor.Actor$class.aroundReceive(Actor.scala:480)
at akka.actor.UntypedActor.aroundReceive(UntypedActor.scala:97)
at akka.actor.ActorCell.receiveMessage(ActorCell.scala:526)
at akka.actor.ActorCell.invoke(ActorCell.scala:495)
at akka.dispatch.Mailbox.processMailbox(Mailbox.scala:257)
at akka.dispatch.Mailbox.run(Mailbox.scala:224)
at akka.dispatch.Mailbox.exec(Mailbox.scala:234)
at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)
at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)
Caused by: org.springframework.web.client.ResourceAccessException: I/O error on POST
request for "http://127.0.0.1:7890/stream/gps": Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:633)
at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:580)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:498)
at org.thingsboard.server.extensions.rest.plugin.RestApiCallMsgHandler.process(RestApiCallMsgHandler.java:48)
... 16 more
Caused by: java.net.ConnectException: Connection refused (Connection refused)
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at java.net.Socket.connect(Socket.java:538)
at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
at sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
at sun.net.www.http.HttpClient.New(HttpClient.java:339)
at sun.net.www.http.HttpClient.New(HttpClient.java:357)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1202)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1138)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1032)
at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:966)
at org.springframework.http.client.SimpleBufferingClientHttpRequest.executeInternal(SimpleBufferingClientHttpRequest.java:78)
at org.springframework.http.client.AbstractBufferingClientHttpRequest.executeInternal(AbstractBufferingClientHttpRequest.java:48)
at org.springframework.http.client.AbstractClientHttpRequest.execute(AbstractClientHttpRequest.java:53)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:619)
... 19 more

我已经快速搭建了一个节点服务器来测试是否正在发送数据。

const express = require('express');
const app = express();
const cors = require('cors');
const bodyParser = require('body-parser');
app.use(cors());
app.use(bodyParser.urlencoded({extended: true}));
app.use(bodyParser.json());
app.all('*', (req, res, next) => {
    console.log('received request');
    next();
});
app.get('/', (req, res, next) => {
    res.status(200).send('It works');
    next();
});
app.post('/stream/gps', (req, res, next) => {
    console.log(req.body);
    res.status(200).json(req.body);
    next();
});
app.listen(7890, () => {
    console.log('Server listening on port 7890');
});

当我 post 失眠或 post 男人 url 时,我获得了 200 成功

发现问题,运行将 Thingsboard 放在 docker 容器中,所以本地主机 === 容器本地主机,而不是我的设备,我 运行 节点服务器