Unable to add nodejslab proxy for coursera training - Failed to connect to backend deployment service

I'm trying to add a Node.js proxy for Week 2 of the coursera training, but the deployment step hangs and then eventually gives me this error:

Failed to connect to backend deployment service: HttpConnectionOverHTTP@61fbe7a4::DecryptedEndPoint@5093f45d{turbo-prod.apigeeks.net/35.237.151.82:443<->/192.168.8.142:60766,OPEN,fill=-,flush=W,to=99610/120000}

What can I do?

Solved Solved
0 4 319
1 ACCEPTED SOLUTION

skazemi
Participant I

Alright, so the solution following this new method is to ensure you have the proper dependencies listed in your package.json file. For this lab, this is what the contents of package.json should be:

{
  "name": "hello-world",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
   "start": "node index.js"
  },
  "author": "",
  "license": "",
  "description": "Hello World Application",
  "dependencies": {
    "async": "^3.2.0",
    "express": "^4.17.1",
    "http": "0.0.1-security",
    "request": "^2.88.2"
  }
}

Then, you can use the following for your index.js:

var express = require('express');
var request = require('request');
var app = express();
app.get('/', function(req, res){
  res.send('hello world');
});
app.get('/hello', function(req, res) {
    var responseObj = {};
    responseObj.message = "Hello from Express";
    res.json(responseObj);
});
app.listen(process.env.PORT || 3000);

View solution in original post

4 REPLIES 4

skazemi
Participant I

I just reached this point as well. It seems like when you choose the "Hello world" option, it fails to install the needed modules (e.g. express) as there is no node_module folder. This is one of the issues highlighted if you look at your runtime logging for this proxy. I am going to try approaching it without using the pre-generated "Hello world" option and will reply back with what I find.

skazemi
Participant I

It looks like the lab is actually deprecated as the traditional way Node.js was supported on Apigee has been retired! The lab needs an update. The new method involves treating the Node.js application as a Hosted Target. Using this method, the node_modules folder is not required unless you have custom modules that aren't available via npm. However, it looks like any dependencies need to be listed in your package.json and you also need a app.yaml file (configuration file that can have, for example, environment variables that will be available to the Node.js application at runtime). Since all these files are included in the new Hello World example, I think if the dependencies are manually included in the package.json files, it should work. Will try and report back.

skazemi
Participant I

Alright, so the solution following this new method is to ensure you have the proper dependencies listed in your package.json file. For this lab, this is what the contents of package.json should be:

{
  "name": "hello-world",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
   "start": "node index.js"
  },
  "author": "",
  "license": "",
  "description": "Hello World Application",
  "dependencies": {
    "async": "^3.2.0",
    "express": "^4.17.1",
    "http": "0.0.1-security",
    "request": "^2.88.2"
  }
}

Then, you can use the following for your index.js:

var express = require('express');
var request = require('request');
var app = express();
app.get('/', function(req, res){
  res.send('hello world');
});
app.get('/hello', function(req, res) {
    var responseObj = {};
    responseObj.message = "Hello from Express";
    res.json(responseObj);
});
app.listen(process.env.PORT || 3000);

I was able to get it working. Thank you!