我想在猎户座和天鹅座之间建立一个工作通知系统。 为此我根据
设置订阅在我的情况下看起来像这样:
(curl localhost:1026/v1/subscribeContext -s -S --header 'Content-Type: application/json' --header 'Accept: application/json' --header 'Fiware-Service: vehicles' --header 'Fiware-ServicePath: /test' -d @- | python -mjson.tool) <<EOF
{
"entities": [
{
"type": "pos-test",
"isPattern": "false",
"id": "test"
}
],
"attributes": [
"x_pos",
"y_pos"
],
"reference": "http://localhost:5050/notify",
"duration": "P1M",
"notifyConditions": [
{
"type": "ONCHANGE",
"condValues": [
"x_pos",
"y_pos"
]
}
],
"throttling": "PT1S"
}
EOF
并且我希望使用以下请求插入数据:
orcb_str = """curl correct.ip:5050/notify -v -s -S --header 'Content-Type: application/json; charset=utf-8' --header 'Accept: application/json' --header "/Fiware-Service: qsg" --header "/Fiware-ServicePath: test" -d @- <<EOF
{{
"subscriptionId" : "5aa6731785e92e6b4cec80fc",
"originator" : "playground",
"contextResponses" : [
{{
"contextElement" : {{
"attributes" : [
{{
"name" : "x_pos",
"type" : "float",
"value" : "{x}"
}},
{{
"name" : "y_pos",
"type" : "float",
"value" : "{y}"
}}
],
"type" : "pos-test",
"isPattern" : "false",
"id" : "test"
}},
"statusCode" : {{
"code" : "200",
"reasonPhrase" : "OK"
}}
}}
]
}}
EOF
"""
双括号和缺失值的格式正确。 在天鹅座结束时,我收到此错误消息:
time=2018-03-12T13:38:58.569Z | lvl=INFO | corr=0c09ed1d-f3f9-4913-884a-b7b937ae2c6c | trans=0c09ed1d-f3f9-4913-884a-b7b937ae2c6c | srv=default | subsrv=/ | comp=cygnus-ngsi | op=getEvents | msg=com.telefonica.iot.cygnus.handlers.NGSIRestHandler[286] : [NGSIRestHandler] Starting internal transaction (0c09ed1d-f3f9-4913-884a-b7b937ae2c6c)
time=2018-03-12T13:38:58.569Z | lvl=INFO | corr=0c09ed1d-f3f9-4913-884a-b7b937ae2c6c | trans=0c09ed1d-f3f9-4913-884a-b7b937ae2c6c | srv=default | subsrv=/ | comp=cygnus-ngsi | op=getEvents | msg=com.telefonica.iot.cygnus.handlers.NGSIRestHandler[304] : [NGSIRestHandler] Received data ({ "subscriptionId" : "5aa674af85e92e6b4cec80fd", "originator" : "playground", "contextResponses" : [ { "contextElement" : { "attributes" : [ { "name" : "x_pos", "type" : "float", "value" : "6.520416" }, { "name" : "y_pos", "type" : "float", "value" : "0.15" }, { "name" : "timestamp", "type" : "float", "value" : "90.884872" }, ], "type" : "pos-test", "isPattern" : "false", "id" : "test" }, "statusCode" : { "code" : "200", "reasonPhrase" : "OK" } } ]})
time=2018-03-12T13:38:58.569Z | lvl=ERROR | corr=0c09ed1d-f3f9-4913-884a-b7b937ae2c6c | trans=0c09ed1d-f3f9-4913-884a-b7b937ae2c6c | srv=default | subsrv=/ | comp=cygnus-ngsi | op=getEvents | msg=com.telefonica.iot.cygnus.handlers.NGSIRestHandler[315] : [NGSIRestHandler] Runtime error (null)
time=2018-03-12T13:38:58.569Z | lvl=ERROR | corr=0c09ed1d-f3f9-4913-884a-b7b937ae2c6c | trans=0c09ed1d-f3f9-4913-884a-b7b937ae2c6c | srv=default | subsrv=/ | comp=cygnus-ngsi | op=warn | msg=org.mortbay.log.Slf4jLog[87] : /notify
java.lang.NullPointerException
at org.apache.flume.source.http.HTTPSource$FlumeHTTPServlet.doPost(HTTPSource.java:199)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:814)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
在发送数据的服务器上我得到:
* Connected to 192.168.0.3 (192.168.0.3) port 5050 (#0)
> POST /notify HTTP/1.1
> User-Agent: curl/7.35.0
> Host: 192.168.0.3:5050
> Content-Type: application/json; charset=utf-8
> Accept: application/json
> /Fiware-Service: qsg
> /Fiware-ServicePath: test
> Content-Length: 949
>
* upload completely sent off: 949 out of 949 bytes
< HTTP/1.1 500 Internal Server Error
< Content-Type: text/html; charset=iso-8859-1
< Cache-Control: must-revalidate,no-cache,no-store
< Content-Length: 2640
* Server Jetty(6.1.26) is not blacklisted
< Server: Jetty(6.1.26)
<
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title>Error 500 INTERNAL_SERVER_ERROR</title>
</head>
<body><h2>HTTP ERROR 500</h2>
<p>Problem accessing /notify. Reason:
<pre> INTERNAL_SERVER_ERROR</pre></p><h3>Caused by:</h3><pre>java.lang.NullPointerException
at org.apache.flume.source.http.HTTPSource$FlumeHTTPServlet.doPost(HTTPSource.java:199)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:725)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:814)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
感谢任何帮助。
(日志文件中显示的时间戳属性刚刚离开 在这里保持更短)