Search code examples
ibm-cloudiot

Bluemix IoT Foundation Starter give Error: Lost connection to server


I am trying the Internet of Things Foundation Starter boilerplate in Bluemix. Here are the steps I am following:

  1. Create a new app using the boilerplate
  2. Once the app is up, I go to the URL and see the NodeRED home page
  3. I click on the button to take me to the NodeRED editor
  4. In another browser window I have the IoT Sensor available here: https://quickstart.internetofthings.ibmcloud.com/iotsensor/ up and running
  5. I configure the "IoT App In Node" with the address of my IoT sensor. I have removed the ":"'s and have made the letters lowercase.
    1. When I click Deploy in the NodeRED editor, I see the following error: "Error: Lost connection to server"

After step 2 I already see these errors in the log:

2015-05-14T16:05:10.31-0400 [App/0]   OUT ←[34m[2015-05-14 20:05:10.316] [TRACE] [default] - ←[39m1 iot-2/type/+/id//evt/+/fmt/json
2015-05-14T16:05:10.31-0400 [App/0]   OUT ←[34m[2015-05-14 20:05:10.316] [TRACE] [default] - ←[39mResubscribing:
2015-05-14T16:05:10.31-0400 [App/0]   OUT ←[34m[2015-05-14 20:05:10.318] [TRACE] [default] - ←[39mRetry count = 1
2015-05-14T16:05:12.32-0400 [App/0]   OUT ←[34m[2015-05-14 20:05:12.320] [TRACE] [default] - ←[39mCONNECTED......:
2015-05-14T16:05:12.32-0400 [App/0]   OUT Subscription Count = 1
2015-05-14T16:05:12.32-0400 [App/0]   OUT ←[34m[2015-05-14 20:05:12.320] [TRACE] [default] - ←[39m1 iot-2/type/+/id//evt/+/fmt/json
2015-05-14T16:05:12.32-0400 [App/0]   OUT ←[34m[2015-05-14 20:05:12.320] [TRACE] [default] - ←[39mResubscribing:
2015-05-14T16:05:12.32-0400 [App/0]   OUT ←[34m[2015-05-14 20:05:12.322] [TRACE] [default] - ←[39mRetry count = 1
2015-05-14T16:05:13.32-0400 [App/0]   OUT ←[34m[2015-05-14 20:05:13.328] [TRACE] [default] - ←[39mCONNECTED......:
2015-05-14T16:05:13.32-0400 [App/0]   OUT Subscription Count = 1

After step 5 after the error happens, I see the following error:

2015-05-14T16:05:17.35-0400 [App/0]   OUT ←[34m[2015-05-14 20:05:17.355] [TRACE] [default] - ←[39m1 iot-2/type/+/id//evt/+/fmt/json
2015-05-14T16:05:17.35-0400 [App/0]   OUT 14 May 20:05:17 - [red] Uncaught Exception:
2015-05-14T16:05:17.35-0400 [App/0]   OUT 14 May 20:05:17 - Error: This method cannot be called until MQTT client has been initialized (see connectMqtt() method)
2015-05-14T16:05:17.35-0400 [App/0]   OUT     at IoTAppClient.checkMqtt (/home/vcap/app/node_modules/node-red-contrib-scx-ibmiotapp/node_modules/iotclient/application/IoTAppClient.
js:340:9)
2015-05-14T16:05:17.35-0400 [App/0]   OUT     at MqttClient.<anonymous> (/home/vcap/app/node_modules/node-red-contrib-scx-ibmiotapp/node_modules/iotclient/application/IoTAppClient.
js:120:9)
2015-05-14T16:05:17.35-0400 [App/0]   OUT     at MqttClient.emit (events.js:117:20)
2015-05-14T16:05:17.35-0400 [App/0]   OUT     at MqttClient._handleConnack (/home/vcap/app/node_modules/node-red-contrib-scx-ibmiotapp/node_modules/iotclient/node_modules/mqtt/lib/
client.js:521:10)
2015-05-14T16:05:17.35-0400 [App/0]   OUT     at Connection.<anonymous> (/home/vcap/app/node_modules/node-red-contrib-scx-ibmiotapp/node_modules/iotclient/node_modules/mqtt/lib/cli
ent.js:191:10)
2015-05-14T16:05:17.35-0400 [App/0]   OUT     at Connection.emit (events.js:95:17)
2015-05-14T16:05:17.35-0400 [App/0]   OUT     at Connection._write (/home/vcap/app/node_modules/node-red-contrib-scx-ibmiotapp/node_modules/iotclient/node_modules/mqtt/lib/connecti
on.js:176:12)
2015-05-14T16:05:17.35-0400 [App/0]   OUT     at doWrite (_stream_writable.js:226:10)
2015-05-14T16:05:17.35-0400 [App/0]   OUT     at writeOrBuffer (_stream_writable.js:216:5)
2015-05-14T16:05:17.35-0400 [App/0]   OUT     at Connection.Writable.write (_stream_writable.js:183:11)
2015-05-14T16:05:17.35-0400 [App/0]   OUT     at write (_stream_readable.js:602:24)
2015-05-14T16:05:17.35-0400 [App/0]   OUT     at flow (_stream_readable.js:611:7)
2015-05-14T16:05:17.38-0400 [App/0]   ERR
2015-05-14T16:05:17.41-0400 [RTR]     OUT testiotsd.mybluemix.net - [14/05/2015:20:04:40 +0000] "GET /red/comms HTTP/1.1" 101 0 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Ge
cko/20100101 Firefox/31.0" 75.126.70.46:60509 x_forwarded_for:"75.126.70.46" vcap_request_id:231a532e-d89e-4236-49e7-7d00a803cd18 response_time:MissingFinishedAt app_id:4cc323b6-d2
48-4fd3-b8ac-c046539a6c2b
2015-05-14T16:05:17.48-0400 [API]     OUT App instance exited with guid 4cc323b6-d248-4fd3-b8ac-c046539a6c2b payload: {"cc_partition"=>"default", "droplet"=>"4cc323b6-d248-4fd3-b8a
c-c046539a6c2b", "version"=>"2778c52b-ac6d-4845-8077-761927982233", "instance"=>"288976a131434a34b033c7d1fd0e812e", "index"=>0, "reason"=>"CRASHED", "exit_status"=>1, "exit_descrip
tion"=>"app instance exited", "crash_timestamp"=>1431633917}

Now if I restart the app everything just works fine. But I can recreate the above scenario consistently every time with these steps:

  1. create new app from boilerplate
  2. go to NodeRED editor
  3. configure IoT in-node
  4. deploy
  5. get error
  6. stop and start runtime
  7. all works

Need help figuring out why this is happening and how to prevent it.

Thanks


Solution

  • Shahir
    A permanent fix has been uploaded in the npmjs and Internet of Things Foundation Starter boilerplate of Bluemix, which resolves this issue.