node js server deployment on heroku - node.js

we are working on a video call application, we used nodejs and socket io for the server. We have arrived at the deployment phase. When deploying the server on heroku it displays Build succeeded but when I launch the link or I click on open app leads to a white page where is written :
Cannot GET /
Any help please
I tried to replace the port process.env.SOCKET_BACKEND_URL || "http://localhost:5000"
bye by the link given while deployment:
process.env.SOCKET_BACKEND_URL ||"https://appname.herokuapp.com/"

Related

WebRtc with nodeJS and react

WebRTC work only in local subnet but after deploy to Heroku stop working correctly. I can not recieve data.
const PC_CONFIG = { 'iceServers': [{url:'stun:stun.l.google.com:19302'} ] };
github code
if you are having issues with Heroku, use the Heroku deploy template listed on the Github Code: .
If you still have errors, please run heroku logs --tail and paste the logs so we can help further.

Microsoft.WindowsAzure Exception: The remote server returned an error: (503)

After I deploy my web app to window Azure.I access my web app,the server return error 503.
it look like the server did not start, the file starter.cmd is empty(only #%*).
log:
2019-08-19T03:23:55.2310991Z,Using start-up script start.js from package.json.,,0
2019-08-19T03:23:55.2310991Z,The iisnode.yml file explicitly sets nodeProcessCommandLine. Automatic node.js version selection is turned off.,,0
2019-08-19T03:23:55.2467314Z,Selected npm version 6.4.1,,0
2019-08-19T03:23:55.2623494Z,The syntax of the command is incorrect.,,1
2019-08-19T03:23:55.2936133Z,The syntax of the command is incorrect.\r\nD:\Program Files (x86)\SiteExtensions\Kudu\84.10807.4030\bin\Scripts\starter.cmd deploy.cmd,,2
You could use Kudu console (https://yoursite.scm.azurewebsites.net) - Review the logs to fetch more on the error -Node.exe crashed – check d:\home\LogFiles\logging-errors.txt for stack trace and check win32 error code for more details.
In Azure App Service, the app is run in IIS using iisnode. To enable the app to run with iisnode, the root app directory contains a web.config file. The file is readable by IIS, and the iisnode-related settings are documented in the iisnode GitHub repository.
You could download the sample Node.js project from https://github.com/Azure-Samples/nodejs-docs-hello-world/archive/master.zip and extract the ZIP archive and change based on your requirement.
Open index.js and find the following line:
const port = process.env.PORT || 1337;
App Service injects process.env.PORT into your application, so the code uses the variable to know which port to listen.
NODE.exe has a setting called NODE_PENDING_PIPE_INSTANCES. On Azure App Service, this value is set to 5000. Meaning that node.exe can accept 5000 requests at a time on the named pipe. This value should be good enough for most node applications running on Azure App Service. You should not see 503.1003 on Azure App Service because of the high value for the NODE_PENDING_PIPE_INSTANCES.
Kindly let us know, I have answered your similar question here.

App Dynamics for Angular 2 App in IIS - Node.js Agent Installation and Configuration

I am trying to assist in setting up AppDynamics with an Angular 2 app that is hosted in IIS. The app is already up and running. There is a part I am having trouble on, the instructions for that part say say:
1) From the root directory of your Node.js application, run this command:
npm install appdynamics#4.3.5
For every Node.js application you are instrumenting, insert the following call in the application source code at the first line of the main module (such as the server.js file), before any other require statements:
require("appdynamics").profile({
controllerHostName: '<controller host name>',
controllerPort: <controller port number>,
controllerSslEnabled: false, // Set to true if controllerPort is SSL
accountName: '<AppDynamics_account_name>',
accountAccessKey: '<AppDynamics_account_key>',
applicationName: 'your_app_name',
tierName: 'choose_a_tier_name',
nodeName: 'choose_a_node_name'
});
2) Restart you application
I did step 1 locally in the console, but I don't know what to do for step 2. If I add that script to the page I get "The Reference error: require is not defined".
I learned that that function is not meant to run on the browser. It's meant to be run server-side, but I do not see node js or any server.js files on our dev web server.
Does anyone have any suggestions on where to put that snippet. Will it even work with the current setup?
It turns out the code I was given was completely wrong for angular 2 implementation. The code they gave me is for running on the web server's side with node js. Since angular 2 is an SPA that runs on the browser, it would never work.
I did some research and found this example application that I added a few tweaks to: https://github.com/derrekyoung/appd-sampleapp-angular2

How to correct a Bluemix Node.js app that can't accept connections

I created a new Node.js app on Bluemix this morning and downloaded the boilerplate code. I worked on it locally and then pushed it up. On Bluemix, it refuses to start. The error according to the logs is:
Instance (index 0) failed to start accepting connections
So I Googled for that, in every case where I found the result, the answer was that my application was trying to use a specific port instead of letting Bluemix set it.
Ok, but I'm setting the host/port with the exact code the boilerplate uses:
var appEnv = cfenv.getAppEnv();
// start server on the specified port and binding host
app.listen(appEnv.port, function() {
// print a message when the server starts listening
console.log("server starting on " + appEnv.url);
});
So if this is incorrect, it means the code Bluemix told me to download itself is incorrect as well, and I can't imagine that is the issue.
To identify whether cfenv is at fault, I've tested that piece of code with a number of more complex Node.js apps I have, and they work perfectly on Bluemix.
That message can also come when an application you've deployed to Bluemix fails to start at all. Here's a few things you can do to troubleshoot your Node.js application on Bluemix.
Tail logs in another terminal while pushing with "cf logs
". Inspect logs after the failure to see if something
failed during the staging process.
Check that your start command in one of two recommended places, scripts.start in package.json or in a Procfile with web: node <start-script>.
Check that your application works locally. First (optional), create a .cfignore file with "/node_modules" in it, so that when you push the app to Bluemix, CF CLI doesn't push your entire folder of node_modules (as they will be installed dynamically). Next, wipe out your node_modules directory and do an npm install --production followed by npm start (or your custom start command). This is what Bluemix does when trying to start your application, so you should double check that it works locally.
Finally, try bumping up your memory, although this is very unlikely that this is why your application fails to start.

Deploying NodeJS application to Openshift

I have working SailsJS app that I want to deploy to Openshift, but as usual it doesn't go smoothly.
Here's what I did so far:
rhc app create myApp nodejs-0.10
rhc cartridge add mongodb-2.4
After these two, I can see that app is created and when I visit given URL, I got Welcome page.
I installed RockMongo, and I see that I can visit my mongodb as well.
Since I already have code, I proceed with following:
git remote add openshift -f <openshift-git-repo-url>
git merge openshift/master -s recursive -X ours
git push openshift HEAD
After I merge my existing code with remote openshift (like in commands above), things start to go wrong.
When I visit url to application, I receive 503 Service temporarily unavailable. If I visit RockMongo and try to login with given credentials, I receive
Unable to connect MongoDB, please check your configurations.
MongoDB said:Failed to connect to: 127.10.37.130:27017: Transport endpoint is not connected.
Also, in Applications Panel, status of my application is building (and stays like that for hours). After pushing code to openshift, application stopped, and after rebuilding it (automatically) I receive some errors, where the last one is
remote: An error occurred executing 'gear postreceive' (exit code: 34)
remote: Error message: CLIENT_ERROR: Failed to execute: 'control build' for /var/lib/openshift/538f1c205004461655000227/nodejs
Does anyone has idea what's going on?
Maybe I didn't set up ports, application url, db url properly? But then again, why RockMongo stopped working?
UPDATE
Here's my mongo config:
mongo: {
module: 'sails-mongo',
user: 'admin',
password: '********',
url: process.env.OPENSHIFT_MONGODB_DB_URL + 'surge'
}
Do I need to set up server_port = process.env.OPENSHIFT_NODEJS_PORT and server_ip_address = process.env.OPENSHIFT_NODEJS_IP as well?
I have some server.js file in root of my application, and I see that these variables are used here.
Here's what I get if I run env | grep NODEJS
OPENSHIFT_NODEJS_PATH_ELEMENT=/var/lib/openshift/538f1c205004461655000227//.node_modules/.bin:/opt/rh/nodejs010/root/usr/bin
OPENSHIFT_NODEJS_PORT=8080
OPENSHIFT_NODEJS_LD_LIBRARY_PATH_ELEMENT=/opt/rh/nodejs010/root/usr/lib64
OPENSHIFT_NODEJS_IDENT=redhat:nodejs:0.10:0.0.17
OPENSHIFT_NODEJS_LOG_DIR=/var/lib/openshift/538f1c205004461655000227/app-root/logs/
OPENSHIFT_NODEJS_IP=127.10.37.129
OPENSHIFT_NODEJS_PID_DIR=/var/lib/openshift/538f1c205004461655000227/nodejs//run/
OPENSHIFT_NODEJS_VERSION=0.10
OPENSHIFT_NODEJS_DIR=/var/lib/openshift/538f1c205004461655000227/nodejs/
and here's what I get for env | grep mongo:
OPENSHIFT_ROCKMONGO_DIR=/var/lib/openshift/538f1c205004461655000227/rockmongo/
PHPRC=/var/lib/openshift/538f1c205004461655000227/rockmongo/etc/conf/php.ini
OPENSHIFT_ROCKMONGO_IDENT=redhat:rockmongo:1.1:0.0.12
OPENSHIFT_MONGODB_IDENT=redhat:mongodb:2.4:0.2.11
OPENSHIFT_MONGODB_DB_URL=mongodb://admin:PASSWORD_HERE#127.10.37.130:27017/
OPENSHIFT_MONGODB_DIR=/var/lib/openshift/538f1c205004461655000227/mongodb/
Just in case someone else stumbles upon this problem, here is what I had to do.
I created separate file config/application.js, and there I placed
module.exports = {
port: process.env.OPENSHIFT_NODEJS_PORT,
host: process.env.OPENSHIFT_NODEJS_IP,
environment: 'production'
};
Also I found what was the problem with application not starting. Post-install was failing (bower install did not finish successfully). To fix it, one should add to scripts section of package.json
"postinstall": "export HOME=/var/lib/openshift/[instance-id]/app-root/runtime/repo; ./node_modules/bower/bin/bower install"

Resources