Getting 502 Bad Gateway Error

We are getting the following error when executing Hosted Functions app:

<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.11.10</center>
</body>
</html>
Solved Solved
0 6 1,672
1 ACCEPTED SOLUTION

  1. Checked the Runtime Logs in the Edge UI and noticed the following error:
    Error: Route.get() requires a callback function but got a [object Undefined]
    at Route.(anonymous function) [as get] (/node_modules/express/lib/router/route.js:202:15)
    at Function.proto.(anonymous function) [as get] (/node_modules/express/lib/router/index.js:510:19)
    at Object.<anonymous> (/build/routes.js:19:8)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/build/app.js:8:16)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Function.Module.runMain (module.js:684:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3
    
  2. Fixed the code /build/app.js to ensure that the proper callback fuction was defined.

This resolved the issue.

View solution in original post

6 REPLIES 6

  1. Checked the Runtime Logs in the Edge UI and noticed the following error:
    Error: Route.get() requires a callback function but got a [object Undefined]
    at Route.(anonymous function) [as get] (/node_modules/express/lib/router/route.js:202:15)
    at Function.proto.(anonymous function) [as get] (/node_modules/express/lib/router/index.js:510:19)
    at Object.<anonymous> (/build/routes.js:19:8)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Module.require (module.js:587:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/build/app.js:8:16)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Function.Module.runMain (module.js:684:10)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:608:3
    
  2. Fixed the code /build/app.js to ensure that the proper callback fuction was defined.

This resolved the issue.

Out of curiosity, where are the "RuntimeLogs"?

@BradKnowles,

The "Runtime Logs" can be seen in the Overview, Development or Trace tab of the Edge UI as shown in the below screenshot:

screen-shot-2018-05-29-at-105511-am.png

The "Runtime Logs" are available for API Proxies that have Hosted Targets. You can read more about Runtime Logs here.

We don't have hosted targets, so I don't see either Build Logs or Runtime Logs as options that are available to me.

Thanks for the information!

@AMAR DEVEGOWDA

I am getting the 502 error on using the HostedTarget with apimocker. The node code works fine locally where as it gives bad gateway error on apigee with no errors on the RuntimeLogs.

attaching the code for your reference.apiproxy.zip

i had the same problem, but i have found the solution, have a look at this, might help out:
https://community.apigee.com/questions/72935/502-bad-gateway-while-using-apimocker-on-hostedtar.html...