wirecloud
wirecloud copied to clipboard
Error occurred when requesting STH-Comet with sth-source-operator from Wirecloud.
Hi @aarranz Cc: @fgalan
I encountered Invalid cookie value
error when requesting STH-Comet with sth-source-operator from Wirecloud.
Response received from STH:
response: "{"statusCode":400,"error":"Bad Request","message":"Invalid cookie value"}"
STH log:
time=2019-02-09T23:25:50.720Z | lvl=WARN | corr=c0a1a597-38f8-488b-b430-7848962341b7 | trans=c0a1a597-38f8-488b-b430-7848962341b7 | op=OPER_STH_GET | from=n/a | srv=test | subsrv=/ | comp=STH | msg=GET /STH/v1/contextEntities/type/Room/id/Room1/attributes/temperature?hLimit=30&hOffset=0, event={"request":"1549754750690:sth-comet:15:jry3yn1l:10000","timestamp":1549754750703,"tags":["state","error"],"data":{"header":"_ga=GA1.2.1613225138.1529842581, _csrf=CxfXpBBwOkX5NWWoxkOJyl1Z, _gid=GA1.2.2115011858.1549664031","errors":[{"name":"_ga","value":"GA1.2.1613225138.1529842581, _csrf=CxfXpBBwOkX5NWWoxkOJyl1Z, _gid=GA1.2.2115011858.1549664031","settings":{"strictHeader":true,"ignoreErrors":false,"isSecure":true,"isHttpOnly":true,"isSameSite":"Strict","path":null,"domain":null,"ttl":null,"encoding":"none"},"reason":"Invalid cookie value"}]},"internal":true}
I checked a request header which Wirecloud sent to STH. It seems that cookie
is a cause of this error.
host : 127.0.0.1:8999
connection : close
user-agent : Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36
accept-encoding : gzip, deflate, br
accept : text/javascript, text/html, application/xml, text/xml, */*
x-real-ip : 192.168.11.70
x-forwarded-for : 192.168.11.70, 172.20.0.1
fiware-service : test
fiware-servicepath : /
x-requested-with : XMLHttpRequest
referer : https://mashup.lab.fisuda.jp/kz-suda/sth
accept-language : ja,en;q=0.9
via : 1.0 mashup.lab.fisuda.jp (Wirecloud-python-Proxy/1.1)
cookie : _ga=GA1.2.1613225138.1529842581, _csrf=CxfXpBBwOkX5NWWoxkOJyl1Z, _gid=GA1.2.2115011858.1549664031
- Workaround 1:
I added
failAction
to lib/server/sthServer.js in fiware-sth-comet. I was able to avoid this error. https://github.com/telefonicaid/fiware-sth-comet/blob/master/lib/server/sthServer.js
server.route([
{
method: 'GET',
path: '/STH/v1/contextEntities/type/{entityType}/id/{entityId}/attributes/{attrName}',
handler: sthGetDataHandler,
config: {
validate: {
headers: sthHeaderValidator,
query: {
lastN: joi.number().integer().greater(-1).optional(),
hLimit: joi.number().integer().greater(-1).optional(),
hOffset: joi.number().integer().greater(-1).optional(),
aggrMethod: joi.string().valid('max', 'min', 'sum', 'sum2', 'occur').optional(),
aggrPeriod: joi.string().required().valid('month', 'day', 'hour', 'minute', 'second').optional(),
dateFrom: joi.date().optional(),
dateTo: joi.date().optional(),
filetype: joi.string().optional(),
count: joi.boolean().optional()
}
},
state: {
"parse": true,
"failAction": "ignore"
}
}
},
-
Workaround 2 : I made a tiny proxy server for cutting in a request from Wirecloud to STH. It rewrites as a request header with only 'fiware-service' and 'fiware-servicepath'. It works well. No error occurred. https://github.com/fisuda/debug.sth.proxy
-
System Environment :
- Wirecloud 1.2.0
- STH source operator (HEAD)
- sth-comet 2.5.0
-
Similar issue : https://github.com/telefonicaid/fiware-sth-comet/issues/418
-
Question : Please give me advice on how to deal with this issue.
Thank you in advance.
If the solution lays in STH side, we don't have any problem to introduce the new parameter. However, not sure if "ignore"
is ok or it should be something taken from the configuration file and properly documented.
@aarranz what do you think?