Help resolve "localhost" variable in json


#1

My app makes use of these port localhost setup to run

 "testnet": {
    "enabled": true,
    "networkType": "testnet",
    "light": true,
    "rpcHost": "localhost",
    "rpcPort": 8545,
    "rpcCorsDomain": "http://localhost:8000",
    "account": {
      "password": "config/testnet/password"
    }

Ive tried changing “localhost” to “0.0.0.0”, but that didn’t work.


Node.js EADDRNOTAVAIL wrong IP address -SOLVED
#2

If you are going to connect to it from your application preview, you may also need to change rpcPort to 8081 and rpcCorsDomain to your workspace preview url


#3
"testnet": {
  "testnet": {
"enabled": true,
"networkType": "testnet",
"light": true,
"rpcHost": "localhost",
"rpcPort": 8082,
"rpcCorsDomain": "http://xxx-xxxxxx.c9users.io:8082",
"account": {
  "password": "config/testnet/password"
    }

result: runtime error
Couldn't connect to http://localhost:8545 are you sure it's on?

browser console log:
Error: CONNECTION ERROR: Couldn't connect to node http://localhost:8545.

The big problem I’m having is that use of port 8545 is hard coded throughout the app framework. So I’m forced to use it. Is there an ENV proxy I could use to globally set port 8545 = 8082??

Essentially I’m successfully using port 8081 for my front end preview. But now port 8545 is for a back-end service I need to connect to. I tried changing 8545 to 8082 but that didnt work. Meanwhile I got my backend service to run successfully on port 8082 (or port 8545).
Listening on localhost:8082

EDITED: error logs added to post


#4

So I guess my question is: Can Cloud9 access port 8545 internally??


#5

If the server is listening on localhost it can use any port.
From the error it seems like you do not need to change the rpcPort and rpcHost at all, since they are not accessed from browser, and are accessed from another node process. (of course this is just a guess as i don’t know anything about your app)

So I guess my question is: Can Cloud9 access port 8545 internally??

Internally all ports are available, but c9users.io exposes only 8080 8081 8082


#6

Exactly, port 8545 is being accessed by another process spawned in another terminal. The app is public on port 8082… and needs to access process on port 8545…

But does the Cross-origin resource sharing CORS allowed in Cloud9?


#7

You need to add usual headers, cloud9 doesn’t change the default behavior of CORS in preview.


#8

Agreed : so to whitelist rpcCorsDomain client side, is it in the app config
[project]-[username].c9users.io:8000 ?
or
c9.io ?
or
c9users.io ?


#9

i think [project]-[username].c9users.io, since the preview runs there, and port 8000 is closed. and probably with http://