Heroku error deployment - heroku

I am trying to deploy, but this error can't let me go.
2017-07-21T02:57:41.976265+00:00 app[web.1]: webpack: Compiled successfully.
2017-07-21T02:57:43.657908+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2017-07-21T02:57:43.658077+00:00 heroku[web.1]: Stopping process with SIGKILL
2017-07-21T02:57:43.988993+00:00 heroku[web.1]: Process exited with status 137
2017-07-21T02:57:44.004007+00:00 heroku[web.1]: State changed from starting to crashed
This is my server config.
const PORT = process.env.PORT || 5000;
app.listen(PORT, 'localhost', err => {
err && console.error(err);
console.log(`Listening at
${chalk.bold.cyan(`http://localhost:${PORT}/`)}`);
});

You shouldn't specify localhost, or node will only listen on the local interface, and the Heroku process manager won't be able to see that your process is actually running.
app.listen(PORT, err => {
err && console.error(err);
console.log(`Listening at
${chalk.bold.cyan(`http://localhost:${PORT}/`)}`);
});

Related

Error: Invalid JSON RPC response: {"size":0,"timeout":0} while using function web3.eth.getBalance()

I'm new to web3 and i have been trying to deploy basic hardhat setup with default Lock.sol template code to heroku and run 'npx hardhat node' with start script.
I have a nodeJs app trying to connect to the hardhat server that is deployed to the above mentioned heroku-hardhat app.
following is my code :
const Web3 = require("web3");
const web3 = new Web3("https://{myapp}.herokuapp.com");
async function getBalance(accountAddress) {
console.log("Get Account balance called", accountAddress);
console.log("web3", web3); // Web3 object is consoled properly here
const balanceInWei = await web3.eth.getBalance(
accountAddress,
(err, balance) => {
if (err) {
console.error("Error while retrieving account balance :", err); // Here, i get the error mentioned in the title
return 0;
}
console.log("Balance : ", web3.utils.fromWei(balance, "ether"), " ETH");
return balance;
}
);
I can also see the accounts and private keys listed from the logs of heroku app once "npx hardhat node" is running
Started HTTP and WebSocket JSON-RPC server at http://127.0.0.1:8545/
But, the app shows the following
2022-12-11T19:11:27.462998+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2022-12-11T19:11:27.490453+00:00 heroku[web.1]: Stopping process with SIGKILL
2022-12-11T19:11:27.639776+00:00 heroku[web.1]: Process exited with status 137
2022-12-11T19:11:27.708051+00:00 heroku[web.1]: State changed from starting to crashed
and the node app is unable to retrieve response, it gets the following consoled :
Error while retrieving account balance : Error: Invalid JSON RPC response: {"size":0,"timeout":0}
But, when i initialise the web3 object with the following, it works properly :
const web3 = new Web3("http://127.0.0.1:8545");
I'm basically trying to send balance of hardhat fake wallet back to frontend through nodeJs app that is unable to get JSON response from the deployed heroku-hardhat app
this error
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within
60 seconds of launch
indicates that your heroku app is not starting. this usually happens if you set your port like this:
const port = 3000;
const server = app.listen(port, () => console.log(`listening on port ${port}`));
in production, heroku assigns an environment variable for port. so you should set the port in your app like this
const port = process.env.PORT || 3000;
Since you were able to deploy the code heroku without issue, this might be the only issue in your app.

Release job on Heroku randomly stops sending Files over FTP

I have an app release process that has been working fine for a week or two and has now randomly stopped working.
My npm app is built with Heroku and a release job then runs that FTPs the static files to another host. I use the npm ftp library to do this. This has randomly stopped working with a timeout error:
Error: Timeout while connecting to server
at Timeout._onTimeout (/app/node_modules/ftp/lib/connection.js:304:24)
at ontimeout (timers.js:436:11)
at tryOnTimeout (timers.js:300:5)
at listOnTimeout (timers.js:263:5)
at Timer.processTimers (timers.js:223:10)
the release script is as follows:
const DIST_PATH = `dist/cineworld-planner`;
const filesList = readdirSync(join(process.cwd(), DIST_PATH));
const client = new Client();
function pushFiles() {
const putFile = bindNodeCallback(client.put.bind(client));
from(filesList).pipe(
mergeMap(fileName => {
const localPath = join(process.cwd(), DIST_PATH, fileName);
console.log(`Putting path ${localPath} to remote ${fileName}`);
return putFile(localPath, fileName);
}, 1)
).subscribe({
complete: () => client.end()
});
}
client.on('ready', () => {
console.log(`READY`);
pushFiles();
});
client.on('error', (error: any) => {
const code = error.code || 'NO_CODE';
console.log(`ERROR: ${code}`);
console.log(error);
process.exit(1);
});
client.connect({
user: process.env.FTP_USER,
host: process.env.FTP_HOST,
password: process.env.FTP_PASSWORD
});
I have asked my host if there are any issues but all they have said is that the IP address that my script reported it was running on was not blocked.
I have tested the script from my home PC and it also works fine from there.
This will be a major pain if this has stopped working. I really don't know what else to try.
Any help very gratefully received.
It turns out that for me the fix was as simple as increasing the timeout:
const connectOptions: Options = {
user: process.env.FTP_USER,
host: process.env.FTP_HOST,
password: process.env.FTP_PASSWORD,
connTimeout: 60000,
pasvTimeout: 60000,
};
client.connect(connectOptions);

Failed to load resource: net::ERR_CONNECTION_REFUSED, socket io, redis

I am having problems starting the node server.js file because the port that it wants to use is taken by Laragon Apache which allows me to open the project in the browser.
This is the node server.js file :
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
var redis = require('redis');
server.listen(8890);
io.on('connection', function (socket) {
console.log("client connected");
var redisClient = redis.createClient();
redisClient.subscribe('message');
redisClient.on("message", function(channel, data) {
console.log("mew message add in queue "+ data['message'] + " channel");
socket.emit(channel, data);
});
socket.on('disconnect', function() {
redisClient.quit();
});
});
When I start it in cmder with node server.js is can not use the port.Node server.js command in cmder:
client connected
events.js:160
throw er; // Unhandled 'error' event
^
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
at Object.exports._errnoException (util.js:1022:11)
at exports._exceptionWithHostPort (util.js:1045:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1087:14)
D:\laragon\www\canvas-messenger\nodejs (master)
node server.js
With Laragon Apache on the browser console looks like this,
Failed to load resource: net::ERR_CONNECTION_REFUSED
and
GET http://localhost:8890/socket.io/?EIO=3&transport=polling&t=1524944736161-36 net::ERR_CONNECTION_REFUSED
error continuously repeting itself because the node server.js can not run I guess.
I have tried installing redis and socket io with laravel echo server, giving them different ports that would allow them to work with out making problems to each other but the functionality of the Chat in the browser would still be lost.
Thank you for reading !

Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED In laravel

when I run node serve.js, getting following error
throw er; // Unhandled 'error' event
^
Error: Redis connection to 127.0.0.1:6379 failed - connect ENFILE 127.0.0.1:6379 - Local (undefined:undefined)
at Object.exports._errnoException (util.js:1018:11)
at exports._exceptionWithHostPort (util.js:1041:20)
at connect (net.js:880:16)
at net.js:969:9
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
Server.js file
var app = require('express')();
var server = require('http').Server(app);
var io = require('socket.io')(server);
var redis = require('redis');
server.listen(8890);
io.on('connection', function (socket) {
console.log("client connected");
var redisClient = redis.createClient();
redisClient.subscribe('message');
redisClient.on("message", function(channel, data) {
console.log("mew message add in queue "+ data['message'] + " channel");
socket.emit(channel, data);
});
socket.on('disconnect', function() {
redisClient.quit();
});
});
How can I fix above error.I have install node,npm,predis and socet.io
I had the same problem but I solved it by installing the redis and executing it previously in the terminal.
If you are using mac you can easily install redis through brew with the follow command:
brew install redis
Run the follow command after install:
redis-serve
This work's for me!
I had this problem in Laravel, the problem was I ran my socket outside of homestead/vagrant box
So SSH into homestead/vagrant navigate to your root project and run your socket script if you experience this in laravel :)

Why does my react app keep crashing on Heroku?

I don't believe I have any config vars to add...
I added npm start in my package.json.
This is my server.js
var app = express();
var compiler = webpack(config);
app.use(webpackDevMiddleware(compiler, {noInfo: true, publicPath: config.output.publicPath}));
app.use(webpackHotMiddleware(compiler));
app.use(express.static('./dist'));
app.use('/', function (req, res) {
res.sendFile(path.resolve('client/index.html'));
});
var port = 8080;
app.listen(port, function(error) {
if (error) throw error;
console.log("Express server listening on port", port);
});
Heroku Activity Log
2016-06-27T05:26:06.606689+00:00 app[web.1]: > POM#0.3.1 start /app
2016-06-27T05:26:06.970312+00:00 app[web.1]: Express server listening on port 8080
2016-06-27T05:26:12.086607+00:00 app[web.1]: webpack built ece2fe8356b0c26f2ade in 5135ms
2016-06-27T05:26:44.560624+00:00 heroku[router]: at=error code=H20 desc="App boot timeout" method=GET path="/" host=pom1.herokuapp.com request_id=77a8ad82-edc4-4dfb-a624-b1a92a5f008c fwd="173.239.65.34" dyno= connect= service= status=503 bytes=
2016-06-27T05:27:04.972688+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
enter code here
It's probably timing out because your app has not connected to the port that heroku provided it. You will be provided with a port number via an environment variable so you should declare your port like this
var port = process.env.PORT || 8080;
That will default to the port specified in the envionment variables (by heroku) and fall back on 8080 if none is set.
I believe the getting started section on heroku touches on this and several other things you should know about deploying to heroku while also providing an example application.

Resources