Installing NodeJS and SocketIO in a Remote Server - javascript

My project is a Real Time Two-Player Facebook Game, and what I need is a tool that will help me build the game with quick responses to enable the "Real Time" function of the game. I have just found out about the Node JS and Socket IO. I have some knowledge in JavaScript so I stepped up and watched a few tutorials that discuss the functions of Node JS and Socket IO.
Here's the link to the videos that I have watched:
http://www.youtube.com/watch?v=mSE6xHkcX0w
I understand the basic of the Node JS and Socket IO and successfully installed it in my localhost. The problem is when I uploaded the files from my localhost to my remote server, some functions of the program are not working well. I don't know how to node my JavaScript file when it is on the server, because if it's in my localhost, I am using command prompt to run it.
node app.js

Node is not a web framework.
Chances are, you're using a web host that's generalized for web frameworks like PHP and Ruby on Rails. You're going to need virtual private server hosting, or Node-specific hosting, because Node requires a virtual machine to run. You otherwise won't be able to run Node Package Manager or Node itself.
Joyent has provided a list of hosts here.
If you chose to use a VPS or dedicated machine, an installation guide would be found here. This is how you would install Node on CentOS.
wget http://nodejs.org/dist/v<version>/node-v<version>.tar.gz
tar -zxf node-v<version>.tar.gz
cd node-v<version>
./configure
make -j <number of cores>
make install

Related

I want to deploy Node.js & React.js projects in same domain and server

As per my Title, I want to deploy Node.js & React.js projects in the same domain and server.
Basically, I want to host the application on cloudways server. https://www.cloudways.com/
I try to host there but due to the same domain action, it is not working as working in the local environment.
Front-end screenshot with package.json script structured(React.js): https://prnt.sc/xT4NAPxt0S99
Back-end screenshot(Node.js): https://prnt.sc/mSg_H4O6prF0
The given screenshot is from a local machine.
As you see here https://prnt.sc/xT4NAPxt0S99 we are using npm run build and after doing the build, we move that folder to the server folder and run npm i && nodemon index.js. It is working well in a single domain or IP in the local server well. But when I do the same process on a live server, it is not working.
Why I am using cloudways server?
For this, I don't need to install and set up MySQL, Node modules, PHP, and other things. Cloudways is doing all things when we create a cloud server.
npm i don't need to run this company on a server.

npm build a vue app and run it on a raspberry Pi

I am creating a Vue app with my roommate and we want to deploy it on our raspberry Pi.
Is there a possibility to npm build our final app on our PC and just start the server on the Pi without having to build the app on the Raspberry? And if so, how can we start the app on the Raspberry?
Thank you in advance!
Totally possible. Build your vue app on your PC (known as development environment) and host it on you raspberry pi (production environment). There multiple ways to do this, but from a high level perspective you just need to:
Set up you pi like normal by installing the preferred OS
SSH into the pi from your PC
Install a webserver. For Vue a quick fix could either be Nginx or Apache
You can install both Node and Git on the webserver through SSH. Then you can git clone the app right into the correct folder. Then with Node installed on the server you can run your npm commands like normal and build the Vue site on the server with npm run build. Otherwise you can just copy your build/dist folder to the server, but then you might need to do some extra configuration.
Get a domain name and point it to your raspberry pi's IP (https://www.noip.com/ is a good free choice I think)
A good list of tutorials to follow is:
How to set up SSH on a raspberri pi
How to set up Nginx or Apache on a raspberri pi
How to deploy a Vue app to a webserver (check both Nginx and Apache). There are some good videos on youtube to check out
Pointing a domain name to my raspberry pi website
NB: One last very important thing to remember is that if you're going to expose your webserver to the internet via your home network (using your own internet at home), you might expose your router to the world, which could enable malicious actors to get into your PC and any other device connected to your network. You might need to think about installing a firewall to prevent this. So maybe check out some research on that too.
Here are some useful links:
https://www.instructables.com/Host-your-website-on-Raspberry-pi/
https://medium.com/#thesabareesh/host-your-own-website-on-a-raspberry-pi-3-e3c8fdb90f90
The result of a vanilla Vue build is a dist directory containing static files.
You can serve them over the network using a static file server: Nginx or Apache for example. The latter I believe is preinstalled in the Raspberry Pi OS and a lot of other distros.
You can also follow this guide as a starting point for Apache.
Also the Vue docs have a page dedicated to deployment.

Connect to OpenVPN server through Node.js

I’m trying to create a GUI client for connecting to OpenVPN servers using electron and node but I’m struggling to figure out how to actually connect to the servers using the .ovpn files.
My question is what is the best way to connect to an OpenVPN server using node? Would it be best to Tun terminal commands like
“openvpn—config path to config”
Or is there another way applications like tunnelblick do it that might be easier or more efficient?
Hello I have been working with electron and ovpn on my last project, so here are a few tips.
VPNs require admin/root privilege in order to get setup, so running child_process.spawn on openvpn --config <path> will fail unless your electron app is being ran via sudo/admin privilege.
You can also use electron-sudo package, link here. This is basically a child process spawn with sudo/admin. Aka, app runs normally, but vpn command runs with sudo.
However, if your client is sketchy about giving you sudo/admin, the VPN must be ran separately prior to launching your app.
All in all its a admin/sudo thing.
Hope this helps.

GraphStream: Interactive Web Application

I'm trying to develop an interactive web application using GraphStream. The idea is to run a couple of community detection algorithms on graphs and visualize them. I wish to use D3.js as graph rendering framework and use GraphStream library in a java websocket server ( Tomcat ) that runs the algorithms. I wish to know if GraphStream already has websocket capabilities that could directly talk to client ( browser ) websocket endpoint. Suggestions for a more correct or feasbile architecture are also welcome.
Great idea. There is a WebSocket implementation that provides GraphStream's event model to the browser. It implements a network protocol, GS-NetStream.
The actual version is compatible with gs-core v1.3.
You can run the exemples from the test/ folder.
In the test folder, run these commands in that order:
Install dependencies : npm install ws express
Compile the Test1.java with gs-core-1.3 in the classpath: javac -cp path/to/gs-core-1.3.jar:. Test1.java
Run the node server : node Test1server.js
Run the Java app :java -cp path/to/gs-core-1.3.jar Test1
go to http://localhost:8080/Test1.html
Use the code in Test1.html as an example for your project

NodeJs talks to ubuntu server on EC2

Recently I have installed a nodejs app on my EC2 directory, listening to one of the port from EC2 instance. I also have a couple of executable python scripts on my EC2 ubuntu Linux server.
The way I run those executable python script is to use putty and connect to ubuntu via command line( for windows, Sure for Mac I use terminal). I am just wondering, is it possible to have the nodejs app does the same job, so I will have a UI based on the web app, which can talk to ubuntu and execute those scripts (python scripts such as "python run.py".
Please advice, thank you!
If I'm understanding correctly, the Python scripts are on the same server as the Node app, and you'd like to run them from Node.js
var execScript = require('child_process').execFile;
execScript('/path/to/python/script.py');
Should probably do the trick.
Can also add options or callbacks as needed, see the docs here: http://nodejs.org/api/child_process.html

Categories