I'm developing a simple API in NodeJS + a telegram bot client in php.
The project is hosted with Heroku with webhook method.
The telegram bot is not responding?
This are the heroku logs of my app:
heroku[router]: at=info method=POST path="/index.php" host=movie-bot-prova.herokuapp.com request_id=9f6da3f1-22c8-4844-804c-7ce15a7fed83 fwd="91.108.6.67" dyno=web.1 connect=0ms service=1ms status=404 bytes=393 protocol=https
This is the Procfile
web: node server.js
This is the package.json
{
"name": "progetto_pdgt",
"version": "1.0.0",
"description": "* [F..... O....... matricola n°286732] (https://github.com/Franci-75)",
"main": "server.js",
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Franci-75/movie-bot-prova.git"
},
"keywords": [],
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/Franci-75/movie-bot-prova/issues"
},
"homepage": "https://github.com/Franci-75/movie-bot-prova#readme",
"dependencies": {
"express": "^4.18.1",
"axios": "0.27.2"
}
}
This is the response of "getWebhookInfo" of my Telegram bot
{"ok":true,"result":{"url":"https://movie-bot-prova.herokuapp.com/index.php","has_custom_certificate":false,"pending_update_count":11,"last_error_date":1657647343,"last_error_message":"Wrong response from the webhook: 404 Not Found","max_connections":40,"ip_address":".............."}}
What am I missing here? It doesn't tell me anything, I don't know where I might have gone wrong?
Maybe you made it in the right way, but the first thing I want to check to help you is how to set webhook, do this (obv put there your token and the https page of yourn script):
https://api.telegram.org/bot TOKEN /setWebhook?url= THE SCRIPT ON YOUR HOST (USE HTTPS)
Example
https://api.telegram.org/bot43h45ui5h123443/setWebhook?url=https://www.example.com/index.php
Just digit in on web
Related
I'm having some issues with a CRUD desktop application I developed with the help of a freelancer. It's an electron-forge build that works seamlessly on Windows 10, and works on MacOS initially when accessing the out folder, the strange thing happens when:
I use npm run publish to zip the Mac/Darwin instance
I manually package.zip the results of npm run make
When I do this, and unzip the file to run, the SQLite integration fails completely. The app appears to be working upon start, but no changes can be made to the DB objects, nor can new objects be made.
The freelancer who put together the DB integration said he was not able to solve this issue, but it's impossible to put apps in marketplaces without zipping the application for delivery. I can post code if necessary, I just don't even know what aspect of the code would be relevant, and feel like there has to be something I can install/put in my package.json that might solve this, but I'm just not sure.
Here is my package.json file in case that is helpful:
{
"name": "C",
"productName": "C",
"version": "1.0.2",
"description": "My Electron application description",
"main": "src/index.js",
"scripts": {
"start": "cross-env NODE_ENV=development electron-forge start",
"package": "electron-forge package",
"make": "cross-env NODE_ENV=production electron-forge make",
"publish": "electron-forge publish",
"lint": "echo \"No linting configured\""
},
"keywords": [],
"author": {
"name": "A",
"email": "xxx#gmail.com"
},
"license": "NA",
"config": {
"forge": {
"packagerConfig": {
"icon": "src/images/n.ico"
},
"makers": [
{
"name": "#electron-forge/maker-squirrel",
"config": {
"name": "C"
}
},
{
"name": "#electron-forge/maker-zip",
"platforms": [
"darwin"
]
},
{
"name": "#electron-forge/maker-deb",
"config": {}
},
{
"name": "#electron-forge/maker-rpm",
"config": {}
}
]
}
},
"dependencies": {
"axios": "^0.21.1",
"bootstrap": "^4.6.0",
"cross-env": "^7.0.3",
"ebay-oauth-nodejs-client": "^1.2.1",
"electron-better-ipc": "^1.1.1",
"electron-squirrel-startup": "^1.0.0",
"electron-store": "^7.0.2",
"jquery": "^3.6.0",
"json-csv": "^3.0.6",
"sequelize": "^6.5.0",
"sqlite3": "^5.0.0"
},
"devDependencies": {
"#electron-forge/cli": "^6.0.0-beta.54",
"#electron-forge/maker-deb": "^6.0.0-beta.54",
"#electron-forge/maker-rpm": "^6.0.0-beta.54",
"#electron-forge/maker-squirrel": "^6.0.0-beta.54",
"#electron-forge/maker-zip": "^6.0.0-beta.54",
"electron": "10.1.5"
}
}
I found that by simply creating a DMG target (see https://www.electronforge.io/config/makers/dmg) that I did not need to worry about unzipping process. I believe DMG is the ideal approach for packaging Mac OS apps that have something like a SQLite database integration within.
I am having a simple Fastify server hosted with Heroku. But, it seems not working ! But, it seemed all right during the development! The error I get is: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch. Full error I am getting:
Here is the code I am using:
server.js:
const fastify = require("fastify")();
const path = require("path");
fastify.register(require("fastify-static"), {
root: path.join(__dirname, "/"),
});
fastify.get("/", function (req, reply) {
reply.sendFile("index.html");
});
fastify.listen(process.env.PORT || 5000, (err) => {
if (err) throw err;
console.log(`server listening on ${fastify.server.address().port}`);
});
package.json:
{
"name": "test1",
"version": "1.0.0",
"description": "",
"main": "server.js",
"engines": {
"node": "15.11.x"
},
"scripts": {
"start": "node server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"fastify": "^3.14.0",
"fastify-static": "^4.0.1"
}
}
Sometimes, the site even doesn't load!
Any help is greatly appreciated !
Thanks !
That's an issue with the library. For other libraries (express, django, etc..) specifying the address is not necessary.
See https://github.com/fastify/fastify/issues/709
Change:
.listen(process.env.PORT)
to:
.listen(process.env.PORT, '0.0.0.0')
When I use both nodemon as local server and Heroku for production the following works for me:
await fastify.listen(process.env.PORT, process.env.HOST || '0.0.0.0');
and in package.json
"dev": "PORT=${PORT:=3000} HOST=${HOST:=localhost} nodemon"
i'm trying to upload a javascript nodejs project to Heroku. Localhost works perfectly but when i try to upload it gives me a:
unable to parse error at :
The Error Message : Unmatched '}' at line 16, column 1
Full Json file:
{
"name": "reactbot",
"version": "1.0.0",
"description": "React bot for webpage",
"main": "index.js",
"engines": {
"node": "12.16.2",
"npm": "6.14.4"
},
"scripts": {
"start": "node index.js"
},
"author": "Ruhul",
"license": "ISC",
"dependencies": {
"express": "^4.17.1",
"nodemon": "^2.0.3"
}
}
The package.json file defines the dependencies that should be installed with your application.
Be sure to use the correct JSON format.
e.g.
{
"name": "node-example",
"version": "1.0.0",
"description": "This example is so cool.",
"main": "web.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"example",
"heroku"
],
"author": "jane-doe",
"license": "MIT",
"dependencies": {
"express": "^4.9.8"
},
"engines": {
"node": "10.x"
}
}
Hello this is my json file format and this works well on my local machine when I run node index.js.
{
"name": "a-simple-nodejs-website",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "node index.js"
},
"author": "Theodore Kelechukwu Onyejiaku",
"license": "ISC"
}
But Heroku tells me:
Application error
An error occurred in the application and your page could not be served...
You need to mention engine in package.json as below
{
"name": "a-simple-nodejs-website",
"version": "1.0.0",
"description": "",
"main": "index.js",
"engines": {
"node": "10.x"
},
"scripts": {
"test": "node index.js"
},
"author": "Theodore Kelechukwu Onyejiaku",
"license": "ISC"
}
Check your Application Port in index.js. if you set to static port change as below:
const PORT = process.env.PORT || 5000
pass this port in your server listen method.
There was no start script in the json file so add => "start": "node index.js".
Fool code sample is below
{
"name": "a-simple-nodejs-website",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "node index.js",
"start": "node index.js"
},
"author": "Theodore Kelechukwu Onyejiaku",
"license": "ISC"
}
I'm trying to Host my bot "chompbot" in Heroku.
But when i change Procfile from web to worker, does not change anything.
I've tried
Here is my package.json
"name": "chompbot",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"discord.js": "^11.5.1",
"mysql": "^2.17.1"
}
}
And here is my Procfile
worker: index.js
When i commit and push, anything happens on "Web", and do not appears "Worker" option
( Ps.: The MySql database is fully working on cloud, so, can't be the dependencies )
Can someone help me to change from Web to Worker?
http://prntscr.com/pb21qs
Your worker should be the script that starts you server, index.js is only the file name. What you want to do is to use your npm start script instead of index.js