Difference between revisions of "NodeJS is not working"
IVSWikiBlue (talk | contribs) (→Start NodeJS in the Shell) |
IVSWikiBlue (talk | contribs) (→Start NodeJS in the Shell) |
||
Line 45: | Line 45: | ||
==Start NodeJS in the Shell== | ==Start NodeJS in the Shell== | ||
− | + | : Type in the following, and then press Enter: <pre>cd /var/www/v3/nodejs</pre> | |
− | + | : Type in this afterwards, and then press Enter: <pre>sudo node server.js</pre> | |
=Causes= | =Causes= |
Revision as of 12:19, 24 April 2019
Contents
Symptoms
If NodeJS is not working properly you may experience one or more of the following symptoms:
- When starting or stopping a recording the buttons do not update.
- When opening the Observe tab, only the following message is displayed:
Diagnosis
There are several possible causes for these issues, but all are related to NodeJS.
Check Connection
To check the connection to NodeJS from the client computer do the following:
- Open the Valt application in Google Chrome.
- Right click on the page and select Inspect from the menu.
- Click on the Console tab.
NodeJS stopped
The nodejs service may be stopped or may have crashed. To check this do the following:
- Connect to the Valt appliance via SSH
- Type in the following, and then press Enter:
ps -ax | grep node
This is a system where NodeJS is not running. | This is a system where NodeJS is running. |
sudo service valtcontrols start
This command will only work on Valt appliances with the command line menu installed. On older Valt systems, or those that were upgraded without installing the command line menu, use the following command:
sudo /usr/local/bin/forever start /var/www/v3/nodejs/index.js
NodeJS is not listening
To check to see if NodeJS is listening for inbound connections do the following:
- Connect to the Valt appliance via SSH
- Type in the following, and then press Enter:
nc -zv 127.0.0.1 8080
This is a system where NodeJS is not listening. | This is a system where NodeJS is listening. |
Start NodeJS in the Shell
- Type in the following, and then press Enter:
cd /var/www/v3/nodejs
- Type in this afterwards, and then press Enter:
sudo node server.js
Causes
Firewall
Issues connecting to NodeJS can be caused by a firewall on the network between the client PC and the Valt appliance. If port 8080 is not open between the PC and the Valt appliance, the client will be unable to connect to NodeJS. If this is the cause of the issue you will be unable to connect to NodeJS from the client pc, but NodeJS will be running and will be listening for inbound connections.
Antivirus
Issues connecting to NodeJS can be caused by a local antivirus on the client PC. If port 8080 is not open between the PC and the Valt appliance, the client will be unable to connect to NodeJS. If this is the cause of the issue you will be unable to connect to NodeJS from the client pc, but NodeJS will be running and will be listening for inbound connections.
Server.js Config Error
If the server has been configured to utilize SSL, but an error was made in the configuration of the server.js file, the NodeJS service may fail to start or may start, but may not listen for connections. This is most likely to occur if the SSL configuration has been performed manually instead of utilizing the provided scripts through the command line menu. This can also occur if a typo is made when entering the key and certificates into the command line menu.
- Connect to the Valt appliance via SSH
- run sudo nano /var/www/v3/nodejs/server.js
- var PORT_SSL = 8080; //working https port
- var sslOptions = {
- key: fs.readFileSync('/etc/apache2/ssl/boonefettercameras.chla.usc.edu.key'$
- cert: fs.readFileSync('/etc/apache2/ssl/boonefettercameras.pem'), //path to$
- ca: fs.readFileSync('/etc/apache2/ssl/boonefettercameras.pem') // path to ca
- };
- var sslOptions = {
- This should specify the path to the key file and the certificates. If there is a typo here, you can manually correct it.
- If the certificate was installed using the command line, the easiest solution may be to disable SSL and reinstall the certificate.
Untrusted Certificate
If the server has been configured to utilize SSL and the certificate used was a self signed certificate or a certificate signed by an internal CA, you may encounter this error because the browser does not trust the certificate. The issue can be overcome in a variety of ways:
- Use a different browser
- Install the certificate and any required intermediate certificates on the computer
- Reissue the certificate with a SAN (can correct issues with google chrome when using an internal CA that is already trusted)
- Issue a certificate from a publicly trusted CA.
Re-issue the certificate with a SAN
- Connect to the Valt appliance via SSH
- run nano csr_details.conf
- Copy and paste the following into nano.
- [req]
- default_bits = 2048
- prompt = no
- default_md = sha256
- req_extensions = req_ext
- distinguished_name = dn
- [ dn ]
- C=US
- ST=New York
- L=Rochester
- O=End Point
- OU=Testing Domain
- emailAddress=your-administrative-address@your-awesome-existing-domain.com
- CN = www.your-new-domain.com
- [ req_ext ]
- subjectAltName = @alt_names
- [ alt_names ]
- DNS.1 = your-new-domain.com
- DNS.2 = www.your-new-domain.com
- Update the information to match your installation. This is the same information you would normally put in a CSR.
- Press ctrl X
- Enter Y
- Press Enter
- run openssl req -new -sha256 -nodes -out your-new-domain.com.csr -newkey rsa:2048 -keyout your-new-domain.com.key -config csr_details.conf
- Make sure to update the csr and key path for your installation.
Wrong Key
If you enter the incorrect key or make a typo when specifying the path to the key file during configuration of SSL, NodeJS will not start. Typically this will also prevent apache from starting. The best solution to this is to disable SSL and then re-enable it and enter the correct key.
Certificate Error
A problem with the certificate will cause NodeJS to fail to start. The most likely cause of this is incorrect encoding on the certificate. The certificate should be PEM encoded. If this is the case, the following will occur:
- Apache will display the site in SSL
- NodeJS may appear to be running
- NodeJS will not be listening.
- Manually starting NodeJS with node /var/www/v3/nodejs/server.js will result in an error.
You can test the certificate by doing the following:
- Run openssl x509 -in certificate.cer -text -noout
- An error similar to the picture above indicates the certificate is not PEM encoded.
- Run openssl x509 -text -inform DER -in certificate.cer
- This command should cause the certificate to display. If it does, the certificate is DER encoded instead of PEM encoded.
- You can convert the certificate from DER to PEM using the following command:
- openssl x509 -inform der -in certificate.cer -out certificate.pem
Once this is complete, reinstall the new certificate.