Reputation: 3
I am new to Bluemix I and was trying out the IoT Connected Vehicle Tutorial http://m2m.demos.ibm.com/dl/iot-connected-vehicle-tutorial.pdf
Everything is working fine until I try to start the Geospatial Analytics Service by accessing the link for my app: http://lm-trafficsim.eu-gb.mybluemix.net/GeospatialService_start
After approximately 1 minute it shows:
502 Bad Gateway: Registered endpoint failed to handle the request.
and the logs are:
[App/0]OUTAbout to call /GeospatialService_start
[App/0]OUTNO BODY
[App/0]OUTOptions prepared: { host: 'streams-broker.eu-gb.bluemix.net',
[App/0]OUT port: '443',
[App/0]OUT headers:
[App/0]OUT method: 'PUT',
[App/0]OUT path: '/jax-rs/geo/start/service_instances/538a9b3d-7160-4235-8e47-9be62d873842/service_bindings/2709488e-2310-4628-acef-df0313877bb5',
[App/0]OUT 'Content-Type': 'application/json',
[App/0]OUT { Authorization: 'Basic YWIxM2I3ODQtMzdmZi00ZGI2LWJkYTctYTgwYzc3MmMwNDY1OjA3YjU0NzMwLWYxM2MtNGYxYi1iZjkzLWY4ZWNlMDEwNDFhYg==',
[App/0]OUTWriting json:
[App/0]OUT 'Content-Length': 448 } }
[App/0]OUTDo the GeospatialService_start call
[App/0]OUT {
[App/0]OUT "mqtt_pw": "xxxxx",
[App/0]OUT "mqtt_uid": "xxxxx",
[App/0]OUT "mqtt_client_id_notify": "a:ybv0lr:geoNotify627",
[App/0]OUT "mqtt_client_id_input": "a:ybv0lr:geoInput393",
[App/0]OUT "mqtt_uri": "ybv0lr.messaging.internetofthings.ibmcloud.com:1883",
[App/0]OUT "device_id_attr_name": "id",
[App/0]OUT "mqtt_notify_topic": "iot-2/type/api/id/geospatial/cmd/geoAlert/fmt/json",
[App/0]OUT "mqtt_input_topics": "iot-2/type/vehicle/id/+/evt/telemetry/fmt/json",
[App/0]OUT "latitude_attr_name": "lat",
[App/0]OUT "longitude_attr_name": "lng"
[App/0]OUT}
[App/0]ERR{ [Error: socket hang up] code: 'ECONNRESET' }
[App/0]OUT[0mGET /GeospatialService_start [0m- [0m- ms - -[0m
[RTR/0]OUTlm-trafficsim.eu-gb.mybluemix.net - [12/05/2016:20:47:37 +0000] "GET /GeospatialService_start HTTP/1.1" 502 0 67 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36" 159.122.215.10:19754 x_forwarded_for:"188.26.151.29" x_forwarded_proto:"http" vcap_request_id:b8812e5c-98dd-4d5a-6c2b-75780c6f0996 response_time:120.113068106 app_id:81052294-dfad-43c6-980f-1f058011632d x_global_transaction_id:"333879271"
I have stopped my firewall as I read in some other posts that it may prevent accessing the port, but that did not help. Any ideas of what could be wrong?
The only difference from the tutorial is that the Geospatial Analytics plan I am using is Standard, not Free, because Standard is the only one I could choose.
Upvotes: 0
Views: 155
Reputation: 41
The article at the PDF you mentioned is old. I'll explain what is wrong with the code and how to fix it.
The example node.js application was written when the Geospatial Analytics service in Bluemix was in beta. The application uses http requests to call the service's REST APIs. When the service switched from beta to production it required using https for REST API access. The service no longer supports REST API access using http. That is what is causing the ECONNRESET in your application log.
To get the existing code working, in the app.js source file change line 462 from:
http = require('http'),
to:
https = require('https'),
And change line 617 from:
var reqPut = http.request(options, function(res) {
to:
var reqPut = https.request(options, function(res) {
After making the changes use cf push
to update your application in Bluemix. When the application restarts you should see successful calls to the Geospatial Analytics REST APIs.
Having said all that, you can also use the final version of the connected car demo article at http://www.ibm.com/developerworks/library/mo-connectedcar-app/index.html. This updated article has a link to the current application code at jazz.net with the fix above in addition to some other enhancements and fixes.
Upvotes: 1