Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
527 views
in Technique[技术] by (71.8m points)

at=error code=H12 desc="Request timeout" in node.js.how to deal with it?

2020-07-21T06:54:58.030920+00:00 heroku[router]:

at=error code=H12
> desc="Request timeout"

method=GET path="/Recipies"

host=desolate-beach-26163.herokuapp.com request_id=25f963a1-ce9e-43c6-a054-72c8a7a33ea8 fwd="157.36.134.120" dyno=web.1 connect=1ms service=30001ms status=503 bytes=0 protocol=httpsenter code here

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The H12 "Request timeout" in Heroku is caused by long running actions. I'm not sure if you're pulling data from a database with this route, but this is a common issue when connecting to data sources from node.js on heroku.

First, check your database connection string, just to make sure that the configuration hasn't been affected. At the beginning of your app (server.js) you can log out the database URL:

console.log("Database_URL", process.env.DATABASE_URL);

After hitting the route (in your case, "/Recipies"), check the logs from your project's directory:

heroku logs --tail

Your connection string should look something like:

postgres://[email protected]:5432/aj48e4ewfjow34

If it doesn't, check your package.json, Procfile, and your index.js file for something that might overwrite DATABASE_URL.

You can verify the connection string by connecting via the "psql" command line tool with your url. It will look something like this (but replace the URL with your connection string) -

psql postgres://[email protected]:5432/aj48e4ewfjow34

If you can connect, it's probably an issue with the way that the postgresql library is being initialized. If you're using the latest "node-postgres" ("pg"), make sure that you have ssl rejectUnauthorized set to false:

const { Pool } = require('pg');
const pool = new Pool({
    connectionString: process.env.DATABASE_URL,
    ssl: { rejectUnauthorized: false }
});

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...