How to make a entity creation? - fiware-orion

I create my Instance on the CLOUD but when try to do a POST the data are not send to the VM, something is wrong with the data I use ?
I'm using Rest Client on Firefox.
This is the body of the code (Json) :
{
"contextElements": [
{
"type": "Room",
"isPattern": "false",
"id": "Room1",
"attributes": [
{
"name": "temperature",
"type": "float",
"value": "23"
},
{
"name": "pressure",
"type": "integer",
"value": "720"
}
]
}
],
"updateAction": "APPEND"
}
The URL is http://10.0.22x.6x:1026/NGSI10/updateContext and the headers are:
Content-Type: application/json
Accept: application/json

Note that you are sending your REST request to a private IP (10.0.22x.6x). However, I guess that you run your Firefox REST Client in a PC or laptop computer without direct connectivity to that IP.
The solution would be to allocate a public IP to the VM, then access to that public IP from your external REST Client. Note that you need the port 1026 opened in the security group associated to that VM (otherwise the cloud will block any attemp to connect to it from an external host).

Related

Registration of non-Java App following Eureka API Documentation - Issue

I have Eureka running in my localhost:8090 . I have independent Java Apps registered in that Eureka and I am able to access them with my Zuul URL which is registered to that Eureka as well.
Now I am have another Python(3.7.3)+Flask App that I am trying to register in same Eureka and access that through same Zuul URL.
My Python app runs fine in local through a DOCKERFILE with these commands -
EXPOSE 8443
CMD ["python", "PythonFlaskSample.py"]
This opens a web-page with this URL -
http://localhost:8443/home
Then to register this App in Eureka, I followed this documentation -
https://github.com/Netflix/eureka/wiki/Eureka-REST-operations
and
https://automationrhapsody.com/json-format-register-service-eureka/
Also trying same through REST clients with POST URL as -
http://localhost:8090/eureka/v2/apps/PythonFlaskApp
Content-Type: application/json
{
"instance": {
"hostName": "localhost",
"app": "PythonFlaskSample",
"vipAddress": "localhost",
"secureVipAddress": "localhost",
"ipAddr": "<Which IP>????",
"status": "STARTING",
"port": {"$": "8090", "#enabled": "true"},
"securePort": {"$": "8443", "#enabled": "true"},
"healthCheckUrl": "http://localhost:8090/health",
"statusPageUrl": "http://localhost:8090/info",
"homePageUrl": "http://localhost:8090",
"dataCenterInfo": {
"#class": "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo",
"name": "MyOwn"
},
}
}
But it is throwing a 405 and no other clue for what happened in Restlet client or Postman.
When I try to put the JSON Payload in python file and use POST from there,
request_body = {
"instance": {
"hostName": "localhost",
"app": "PythonFlaskSample",
"vipAddress": "localhost",
"secureVipAddress": "localhost",
"ipAddr": "<Which IP>????",
"status": "STARTING",
"port": {"$": "8090", "#enabled": "true"},
"securePort": {"$": "8443", "#enabled": "true"},
"healthCheckUrl": "http://localhost:8090/health",
"statusPageUrl": "http://localhost:8090/info",
"homePageUrl": "http://localhost:8090",
"dataCenterInfo": {
"#class": "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo",
"name": "MyOwn"
},
}
}
data=json.dumps(request_body)
url="http://localhost:8090"
response = requests.post(url,data=json.dumps(request_body), headers = {'Content-type':'application/json'}).json()
print(response)
it shows following error-
docker run -p 8443:8443 dockerpython {'timestamp': 1555717403333,
'status': 405, 'error': 'Method Not Allowed', 'exception':
'org.springframework.web.HttpRequestMethodNotSupportedException',
'message': "Request method 'POST' not supported", 'path': '/'}
What am I missing ?
This is an error with Eureka API documentation in - https://github.com/Netflix/eureka/wiki/Eureka-REST-operations. Once I tried same REST URLs without "/v2" , everything worked fine.enter image description here

What is the best way to configuring multiple proxy urls for multiple services in wiremock?

I am using WireMock for service virtualization. I am using proxying functionality to forward all the unmatched requests to the live url. The problem is I am virtualizing 5 different services, how can I provide proxy urls for each service to forward it to corresponding live url in case of mismatch?
As of now I am using 5 different json files with proxyBaseUrl and high priority and setting them by default after starting the service. Is there any better way to configure multiple proxy urls for multiple services?
{
"request": {
"method": "POST",
"urlPattern": "/a/.*"
},
"response": {
"proxyBaseUrl" : "https://srvc1.com"
},
"priority": 10
}
{
"request": {
"method": "POST",
"urlPattern": "/b/.*"
},
"response": {
"proxyBaseUrl" : "https://srvc2.com"
},
"priority": 10
}
{
"request": {
"method": "POST",
"urlPattern": "/e/.*"
},
"response": {
"proxyBaseUrl" : "https://srvc5.com"
},
"priority": 10
}
There is currently no support for importing multiple request/response pairs in the same json file.

Fiware Orion subscription to STH in NGSI V2 with legacy values

Im working with sth, with ngsi v1 i dont have any problems. When i try to use it with ngsi v2 ( trough legacy values) im having several problems.
Im creating a subscription in v2 in this way:
POST /v2/subscriptions HTTP/1.1
Host: <orion-context-broker-host>:<orion-context-broker-port>
Content-Type: application/json
fiware-service: xxxx
fiware-servicepath: /xxxx
{
"description": "Probando legacy",
"subject": {
"entities": [
{
"id": "sthlegacy2",
"type": "NGSIV2"
}
],
"condition": {
"attrs": []
}
},
"notification": {
"attrsFormat":"legacy",
"http": {
"url": "http://<sth-host>:<sth-port>/notify"
},
"attrs": []
},
"expires": "2040-01-01T14:00:00.00Z",
"throttling": 0
}
The subscription is well created but when i try to update a value the subscription state changes to "failed", and it does not create anything in sth.
I would appreciate a solution, something I must be doing wrong.

presto: Discovery server cannot get connect

Recently I build presto with cluster mode, 1 coordinator & 1 worker, it works.
Then I repackage "presto-main-0.148.jar" without any change , and replace it to production environment, it doesn't work! Always get response with "No worker nodes available"
I search the Server.log and see below messages:
ERROR Discovery-0 io.airlift.discovery.client.CachingServiceSelector Cannot
connect to discovery server for refresh (collector/general): Lookup
of collector failed for
ht*p://10.3.2.33:18080/v1/service/collector/general
ERROR Discovery-0 io.airlift.discovery.client.CachingServiceSelector Cannot
connect to discovery server for refresh (presto/general): Lookup of
presto failed for ht*p://10.3.2.33:18080/v1/service/presto/general
INFO Discovery-1 io.airlift.discovery.client.CachingServiceSelector Discovery
server connect succeeded for refresh (collector/general)
INFO Discovery-2 io.airlift.discovery.client.CachingServiceSelector Discovery
server connect succeeded for refresh (presto/general)
So I guess discover server is not started,But I use command curl "h*tp://10.3.2.33:18080/v1/service/collector/general",
and get response below, and I also get coordinator status as 'ACTIVE'
{
"environment": "presto_**_flt",
"services": [
{
"id": "954e886d-7506-4f00-b954-eeab49209835",
"nodeId": "4c0f2596-7e6e-11e6-ae22-56b6b6499611",
"type": "presto",
"pool": "general",
"location": "/4c0f2596-7e6e-11e6-ae22-56b6b6499611",
"properties": {
"node_version": "a0e36ae",
"coordinator": "false",
"http": "h*tp://10.3.2.24:18080",
"http-external": "h*tp://10.3.2.24:18080",
"datasources": "hive,system"
}
},
{
"id": "6790b522-cd17-48ef-b077-e4e8fa97e310",
"nodeId": "4c0f2366-7e6e-11e6-ae22-56b6b6499611",
"type": "presto",
"pool": "general",
"location": "/4c0f2366-7e6e-11e6-ae22-56b6b6499611",
"properties": {
"node_version": "c34bef3-dirty",
"coordinator": "true",
"http": "h*tp://10.3.2.33:18080",
"http-external": "h*tp://10.3.2.33:18080",
"datasources": ""
}
}
]
}
I think this is because that you have two different node_version in these two services.
If you are repackaging presto-main or any other component, make sure you are using the same binaries on all the nodes.

No Notification from Orion Context Broker

I am working with the Orion Context Broker and wanna get notifications for the following subscription, added to orion.lab.fiware.org:1026:
curl -v orion.lab.fiware.org:1026/v2/subscriptions -X POST -s -S --header 'Content-Type: application/json' --header "X-Auth-Token: <myToken>" -d #- <<EOF
{
"description": "A subscription to get info about Room1",
"subject": {
"entities": [
{
"id": "11582",
"type": "User"
}
],
"condition": {
"attrs": [
"temperature"
]
}
},
"notification": {
"http": {
"url": "http://<myIPAddress>:8080"
},
"attrs": [
"temperature"
]
},
"expires": "2040-01-01T14:00:00.00Z",
"throttling": 5
}
EOF
myToken: the token generated by the FIWARE server
myIPAddress: the IP address of my PC
However, in my sample HTTP server program (Node.js) on port 8080 I do not receive any notifications. I should note that after adding the above subscription, I add the entity with id 11582 through another POST request to orion.lab.fiware.org:1026/v2/entities.
When I read later the added subscription, it confirms that the notification has been sent (through lastNotification):
{
"id": "5768088c70dce43aa351cf9b",
"description": "A subscription to get info about Room1",
"expires": "2040-01-01T14:00:00.00Z",
"status": "active",
"subject": {
"entities": [
{
"id": "11582",
"idPattern": "",
"type": "User"
}
],
"condition": {
"attrs": [
"temperature"
]
}
},
"notification": {
"timesSent": 1,
"lastNotification": "2016-06-20T15:16:04.00Z",
"attrs": [
"temperature"
],
"attrsFormat": "normalized",
"http": {
"url": "http://<myIPAddress>:8080"
}
},
"throttling": 5
}
Any idea why I do not receive the notification i my HTTP server program? My firewall is also off.
Thanks!
The following test has been donde in orion.lab.fiware.org. The termina1l.txt file shows the subscriptions and entity creation request sent to Orion (note we use localhost:10026, as the test has been done in the orion.lab.fiware.org host itself) and terminal2.txt file shows the notification received at the listener process (nc).
We have also done the same test (using UserTest2 type this time) running the listener on a VM machine at FIWARE Lab (which IP cannot be disclosed for security reasons) with the 1028 port openend in the Security Group and everything worked fine again, getting:
POST / HTTP/1.1
user-agent: orion/1.2.1 libcurl/7.19.7
host: 130.206.112.29:1028
accept: application/json
content-length: 146
content-type: application/json; charset=utf-8
fiware-correlator: 0870b41c-378d-11e6-910f-52540003a38e
ngsiv2-attrsformat: normalized
X-Forwarded-For: 127.0.0.1
Connection: keep-alive
{"subscriptionId":"5768ff6a70dce43aa351cfaa","data":[{"id":"11582","type":"UserTest2","temperature":{"type":"Float","value":23.5,"metadata":{}}}]}
Thus, I understand that something between orion.lab.fiware.org and your process is blocking the traffic. Note that apart for the firewall running in your machine (which you mention is off) another firewall layer could be blocking (e.g. FIWARE cloud or AWS cloud security group, coorporate firewalls, etc.)