Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getCommand is returning bad content-type #582

Closed
AlvaroVega opened this issue Jul 20, 2021 · 4 comments
Closed

getCommand is returning bad content-type #582

AlvaroVega opened this issue Jul 20, 2021 · 4 comments

Comments

@AlvaroVega
Copy link
Member

AlvaroVega commented Jul 20, 2021

curl -i -X GET 'http://localhost:7897/iot/json?k=3ballfrt3t4s0e6yrucfe91cx&i=disp1&getCmd=1'
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: text/html; charset=utf-8
Content-Length: 20
ETag: W/"14-Nb0rFgrHgIzgTAOGKlZeMQdva9E"
Date: Tue, 20 Jul 2021 07:50:33 GMT
Connection: keep-alive
Keep-Alive: timeout=5

{"reset":{"s":"34"}}

@AlvaroVega
Copy link
Member Author

time=2021-07-20T07:55:33.932Z | lvl=DEBUG | corr=9b2c5301-2d0d-4adf-85d2-48d86f02992d | trans=9b2c5301-2d0d-4adf-85d2-48d86f02992d | op=IOTAJSON.HTTP.Binding | from=n/a | srv=n/a | subsrv=n/a | msg=Parsing payload [undefined] | comp=IoTAgent
time=2021-07-20T07:55:33.932Z | lvl=DEBUG | corr=9b2c5301-2d0d-4adf-85d2-48d86f02992d | trans=9b2c5301-2d0d-4adf-85d2-48d86f02992d | op=IOTAJSON.HTTP.Binding | from=n/a | srv=n/a | subsrv=n/a | msg=Parsed data: [undefined] | comp=IoTAgent
time=2021-07-20T07:55:33.932Z | lvl=DEBUG | corr=9b2c5301-2d0d-4adf-85d2-48d86f02992d | trans=9b2c5301-2d0d-4adf-85d2-48d86f02992d | op=IOTAJSON.HTTP.Binding | from=n/a | srv=n/a | subsrv=n/a | msg=Processing multiple HTTP measures for device [disp1] with apiKey [3ballfrt3t4s0e6yrucfe91cx] | comp=IoTAgent
time=2021-07-20T07:55:33.932Z | lvl=DEBUG | corr=9b2c5301-2d0d-4adf-85d2-48d86f02992d | trans=9b2c5301-2d0d-4adf-85d2-48d86f02992d | op=IoTAgentNGSI.MongoDBGroupRegister | from=n/a | srv=n/a | subsrv=n/a | msg=Looking for group params ["resource","apikey"] with queryObj {"resource":"/iot/json","apikey":"3ballfrt3t4s0e6yrucfe91cx"} | comp=IoTAgent
time=2021-07-20T07:55:33.935Z | lvl=DEBUG | corr=aab505ae-a473-4b10-832f-238589af73fc | trans=aab505ae-a473-4b10-832f-238589af73fc | op=IoTAgentNGSI.MongoDBGroupRegister | from=n/a | srv=smartcity | subsrv=/ | msg=Device group data found: {"_id":"60f67d0f444af642c001857d","commands":[],"staticAttributes":[],"attributes":[],"resource":"/iot/json","apikey":"3ballfrt3t4s0e6yrucfe91cx","type":"thing","service":"smartcity","subservice":"/","description":"mijson","timestamp":true} | comp=IoTAgent
time=2021-07-20T07:55:33.935Z | lvl=DEBUG | corr=aab505ae-a473-4b10-832f-238589af73fc | trans=aab505ae-a473-4b10-832f-238589af73fc | op=IoTAgentNGSI.MongoDBDeviceRegister | from=n/a | srv=smartcity | subsrv=/ | msg=Looking for device with id [disp1]. | comp=IoTAgent
time=2021-07-20T07:55:33.937Z | lvl=DEBUG | corr=aab505ae-a473-4b10-832f-238589af73fc | trans=aab505ae-a473-4b10-832f-238589af73fc | op=IoTAgentNGSI.MongoDBDeviceRegister | from=n/a | srv=smartcity | subsrv=/ | msg=Device data found: {"_id":"60f67d22444af63f8001857e","commands":[{"name":"reset","type":"command","value":"","object_id":"reset"}],"staticAttributes":[],"subscriptions":[],"creationDate":"2021-07-20T07:37:06.034Z","id":"disp1","type":"thing","name":"thing:disp1","service":"smartcity","subservice":"/","registrationId":"60f67d227b1a8008887be3fd","internalId":null,"apikey":"3ballfrt3t4s0e6yrucfe91cx","protocol":"IoTA-JSON","transport":"HTTP","polling":true,"timestamp":true,"explicitAttrs":false} | comp=IoTAgent
time=2021-07-20T07:55:33.937Z | lvl=DEBUG | corr=aab505ae-a473-4b10-832f-238589af73fc | trans=aab505ae-a473-4b10-832f-238589af73fc | op=IoTAgentNGSI.DeviceService | from=n/a | srv=smartcity | subsrv=/castillos | msg=deviceData before merge with conf: {"_id":"60f67d22444af63f8001857e","commands":[{"name":"reset","type":"command","value":"","object_id":"reset"}],"staticAttributes":[],"subscriptions":[],"creationDate":"2021-07-20T07:37:06.034Z","id":"disp1","type":"thing","name":"thing:disp1","service":"smartcity","subservice":"/","registrationId":"60f67d227b1a8008887be3fd","internalId":null,"apikey":"3ballfrt3t4s0e6yrucfe91cx","protocol":"IoTA-JSON","transport":"HTTP","polling":true,"timestamp":true,"explicitAttrs":false} | comp=IoTAgent
time=2021-07-20T07:55:33.938Z | lvl=DEBUG | corr=aab505ae-a473-4b10-832f-238589af73fc | trans=aab505ae-a473-4b10-832f-238589af73fc | op=IoTAgentNGSI.DeviceService | from=n/a | srv=smartcity | subsrv=/castillos | msg=deviceData after merge with conf: {"_id":"60f67d22444af63f8001857e","commands":[{"name":"reset","type":"command","value":"","object_id":"reset"}],"staticAttributes":[],"subscriptions":[],"creationDate":"2021-07-20T07:37:06.034Z","id":"disp1","type":"thing","name":"thing:disp1","service":"smartcity","subservice":"/","registrationId":"60f67d227b1a8008887be3fd","internalId":null,"apikey":"3ballfrt3t4s0e6yrucfe91cx","protocol":"IoTA-JSON","transport":"HTTP","polling":true,"timestamp":true,"explicitAttrs":false,"lazy":null,"active":[]} | comp=IoTAgent
time=2021-07-20T07:55:33.938Z | lvl=DEBUG | corr=aab505ae-a473-4b10-832f-238589af73fc | trans=aab505ae-a473-4b10-832f-238589af73fc | op=IoTAgentNGSI.DomainControl | from=n/a | srv=smartcity | subsrv=/castillos | msg=response-time: 3393919 | comp=IoTAgent
time=2021-07-20T07:55:33.938Z | lvl=DEBUG | corr=503da788-d4b0-49db-b129-d014759fdf82 | trans=503da788-d4b0-49db-b129-d014759fdf82 | op=IoTAgentNGSI.CommandService | from=n/a | srv=smartcity | subsrv=/castillos | msg=Listing all commands for device [disp1] | comp=IoTAgent
time=2021-07-20T07:55:33.944Z | lvl=DEBUG | corr=503da788-d4b0-49db-b129-d014759fdf82 | trans=503da788-d4b0-49db-b129-d014759fdf82 | op=IoTAgentNGSI.MongoDBGroupRegister | from=n/a | srv=n/a | subsrv=n/a | msg=Looking for group params ["resource","apikey"] with queryObj {"apikey":"3ballfrt3t4s0e6yrucfe91cx"} | comp=IoTAgent
time=2021-07-20T07:55:33.944Z | lvl=DEBUG | corr=503da788-d4b0-49db-b129-d014759fdf82 | trans=503da788-d4b0-49db-b129-d014759fdf82 | op=IoTAgentNGSI.CommandService | from=n/a | srv=smartcity | subsrv=/ | msg=Removing command [reset] from device [disp1] | comp=IoTAgent
time=2021-07-20T07:55:33.944Z | lvl=DEBUG | corr=503da788-d4b0-49db-b129-d014759fdf82 | trans=503da788-d4b0-49db-b129-d014759fdf82 | op=IoTAgentNGSI.MongoDBCommandRegister | from=n/a | srv=smartcity | subsrv=/ | msg=Removing command for service [smartcity] subservice [/] and DeviceID [disp1] with name [reset] | comp=IoTAgent
time=2021-07-20T07:55:33.945Z | lvl=DEBUG | corr=503da788-d4b0-49db-b129-d014759fdf82 | trans=503da788-d4b0-49db-b129-d014759fdf82 | op=IoTAgentNGSI.MongoDBCommandRegister | from=n/a | srv=smartcity | subsrv=/ | msg=Looking for command [reset] for device [disp1] | comp=IoTAgent
time=2021-07-20T07:55:33.950Z | lvl=DEBUG | corr=503da788-d4b0-49db-b129-d014759fdf82 | trans=503da788-d4b0-49db-b129-d014759fdf82 | op=IoTAgentNGSI.MongoDBGroupRegister | from=n/a | srv=smartcity | subsrv=/ | msg=Device group data found: {"_id":"60f67d0f444af642c001857d","commands":[],"staticAttributes":[],"attributes":[],"resource":"/iot/json","apikey":"3ballfrt3t4s0e6yrucfe91cx","type":"thing","service":"smartcity","subservice":"/","description":"mijson","timestamp":true} | comp=IoTAgent
time=2021-07-20T07:55:33.950Z | lvl=DEBUG | corr=503da788-d4b0-49db-b129-d014759fdf82 | trans=503da788-d4b0-49db-b129-d014759fdf82 | op=IoTAgentNGSI.NGSIService | from=n/a | srv=smartcity | subsrv=/ | msg=executeWithDeviceInfo entityName thing:disp1 type undefined apikey 3ballfrt3t4s0e6yrucfe91cx attributes [{"name":"reset_status","type":"commandStatus","value":"DELIVERED"},{"name":"reset_info","type":"commandResult","value":" "}] deviceInformation {"_id":"60f67d22444af63f8001857e","commands":[{"name":"reset","type":"command","value":"","object_id":"reset"}],"staticAttributes":[],"subscriptions":[],"creationDate":"2021-07-20T07:37:06.034Z","id":"disp1","type":"thing","name":"thing:disp1","service":"smartcity","subservice":"/","registrationId":"60f67d227b1a8008887be3fd","internalId":null,"apikey":"3ballfrt3t4s0e6yrucfe91cx","protocol":"IoTA-JSON","transport":"HTTP","polling":true,"timestamp":true,"explicitAttrs":false,"lazy":null,"active":[]} | comp=IoTAgent
time=2021-07-20T07:55:33.951Z | lvl=DEBUG | corr=503da788-d4b0-49db-b129-d014759fdf82 | trans=503da788-d4b0-49db-b129-d014759fdf82 | op=IoTAgentNGSI.MongoDBGroupRegister | from=n/a | srv=n/a | subsrv=n/a | msg=Looking for group params ["type"] with queryObj {} | comp=IoTAgent
time=2021-07-20T07:55:33.954Z | lvl=DEBUG | corr=503da788-d4b0-49db-b129-d014759fdf82 | trans=503da788-d4b0-49db-b129-d014759fdf82 | op=IoTAgentNGSI.MongoDBGroupRegister | from=n/a | srv=smartcity | subsrv=/castillos | msg=Device group data found: {"_id":"60cb0b92faee7809c9d5406e","commands":[],"staticAttributes":[],"attributes":[],"resource":"/iot/json","apikey":"hw4hpvgnxeqzcbqktgl19agke","type":"thing","service":"smartcity","subservice":"/castillos","description":"mijson","timestamp":true} | comp=IoTAgent
time=2021-07-20T07:55:33.954Z | lvl=DEBUG | corr=503da788-d4b0-49db-b129-d014759fdf82 | trans=503da788-d4b0-49db-b129-d014759fdf82 | op=IoTAgentNGSI.NGSIUtils | from=n/a | srv=smartcity | subsrv=/ | msg=typeInformation {"_id":"60f67d22444af63f8001857e","commands":[{"name":"reset","type":"command","value":"","object_id":"reset"}],"staticAttributes":[],"subscriptions":[],"creationDate":"2021-07-20T07:37:06.034Z","id":"disp1","type":"thing","name":"thing:disp1","service":"smartcity","subservice":"/","registrationId":"60f67d227b1a8008887be3fd","internalId":null,"apikey":"3ballfrt3t4s0e6yrucfe91cx","protocol":"IoTA-JSON","transport":"HTTP","polling":true,"timestamp":true,"explicitAttrs":false,"lazy":null,"active":[]} | comp=IoTAgent
time=2021-07-20T07:55:33.955Z | lvl=DEBUG | corr=503da788-d4b0-49db-b129-d014759fdf82 | trans=503da788-d4b0-49db-b129-d014759fdf82 | op=IoTAgentNGSI.Entities-v2 | from=n/a | srv=smartcity | subsrv=/ | msg=typeInformation: {"_id":"60f67d22444af63f8001857e","commands":[{"name":"reset","type":"command","value":"","object_id":"reset"}],"staticAttributes":[],"subscriptions":[],"creationDate":"2021-07-20T07:37:06.034Z","id":"disp1","type":"thing","name":"thing:disp1","service":"smartcity","subservice":"/","registrationId":"60f67d227b1a8008887be3fd","internalId":null,"apikey":"3ballfrt3t4s0e6yrucfe91cx","protocol":"IoTA-JSON","transport":"HTTP","polling":true,"timestamp":true,"explicitAttrs":false,"lazy":null,"active":[]} | comp=IoTAgent
time=2021-07-20T07:55:33.955Z | lvl=DEBUG | corr=503da788-d4b0-49db-b129-d014759fdf82 | trans=503da788-d4b0-49db-b129-d014759fdf82 | op=IoTAgentNGSI.Entities-v2 | from=n/a | srv=smartcity | subsrv=/ | msg=Updating device value in the Context Broker at [http://iot-orion:1026/v2/entities/thing:disp1/attrs?type=thing] | comp=IoTAgent
time=2021-07-20T07:55:33.955Z | lvl=DEBUG | corr=503da788-d4b0-49db-b129-d014759fdf82 | trans=503da788-d4b0-49db-b129-d014759fdf82 | op=IoTAgentNGSI.Entities-v2 | from=n/a | srv=smartcity | subsrv=/ | msg=Using the following NGSI v2 request:

{
"url": "http://iot-orion:1026/v2/entities/thing:disp1/attrs?type=thing",
"method": "POST",
"headers": {
"fiware-service": "smartcity",
"fiware-servicepath": "/"
},
"json": {
"reset_status": {
"type": "commandStatus",
"value": "DELIVERED",
"metadata": {
"TimeInstant": {
"type": "DateTime",
"value": "2021-07-20T07:55:33.955Z"
}
}
},
"reset_info": {
"type": "commandResult",
"value": " ",
"metadata": {
"TimeInstant": {
"type": "DateTime",
"value": "2021-07-20T07:55:33.955Z"
}
}
},
"TimeInstant": {
"type": "DateTime",
"value": "2021-07-20T07:55:33.955Z"
}
}
}

| comp=IoTAgent
time=2021-07-20T07:55:33.962Z | lvl=DEBUG | corr=503da788-d4b0-49db-b129-d014759fdf82 | trans=503da788-d4b0-49db-b129-d014759fdf82 | op=IoTAgentNGSI.MongoDBCommandRegister | from=n/a | srv=smartcity | subsrv=/ | msg=Command [reset] not found for removal. | comp=IoTAgent
time=2021-07-20T07:55:33.962Z | lvl=ERROR | corr=503da788-d4b0-49db-b129-d014759fdf82 | trans=503da788-d4b0-49db-b129-d014759fdf82 | op=IOTAJSON.HTTP.Binding | from=n/a | srv=smartcity | subsrv=/ | msg=Error updating command status after delivering commands for device [disp1] | comp=IoTAgent
time=2021-07-20T07:55:33.967Z | lvl=INFO | corr=503da788-d4b0-49db-b129-d014759fdf82 | trans=503da788-d4b0-49db-b129-d014759fdf82 | op=IoTAgentNGSI.Entities-v2 | from=n/a | srv=smartcity | subsrv=/ | msg=Received the following response from the CB: Value updated successfully
| comp=IoTAgent

@AlvaroVega
Copy link
Member Author

AlvaroVega commented Jul 20, 2021

Response is created in:

res.status(200).send(JSON.stringify(list.commands.map(parseCommand).reduce(concatCommand, {})));

command returned as stringified, so is text/html content-type

@AlvaroVega
Copy link
Member Author

AlvaroVega commented Jul 20, 2021

The same implementation is found in UL iotagent also

https://github.com/telefonicaid/iotagent-ul/blob/4856b9bde19708247c08385f63913cc4c42ca83d/lib/bindings/HTTPBindings.js#L198-L211

curl -i -X GET 'http://localhost:7896/iot/d?k=0a1hklrll9p8o2xzzdb3t5063&i=disp3&getCmd=1'
HTTP/1.1 200 OK
X-Powered-By: Express
Content-Type: text/html; charset=utf-8
Content-Length: 16
ETag: W/"10-qjxBJ6diMRAMIjnHPy48XmcadZE"
Date: Tue, 20 Jul 2021 10:21:28 GMT
Connection: keep-alive

disp3@close|s=36

@fgalan
Copy link
Member

fgalan commented Jul 21, 2021

Fixed by PR #583

@fgalan fgalan closed this as completed Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants