WebSocket Server php script - javascript

I'm building a chat system with websockets but a can't find how to keep runing the file that starts the websocket server. I'm using php, javascript and cpanel. Can anyone help me how to run the websocket server from cpanel and keep it runing like forever.
Thanks

you have to use ssh detail to connect your server from command prompt
ssh username#host-name

Related

Autorun file when you connect to vagrant server

I am currently working on a server where I want to autorun a file whenever I connect to the server myself. Example; I start the server and when I connect to it I want it to run a backup. My server is running on another computer and I connect to it from my main computer to save performance. The thing is that I also want to be able to work inside the server from my main computer. Example; The server is running on PC1 and I want to have access to the server from PC2 via vagrant.
The server is run by vagrant.
I have some experience within - Ruby, C++, Vagrant, javascript and SQL if this is helpful for the answer.
I found how to connect to the server remotely via the vagrant environment using ssh vagrant#192.168.x.x where the x.x is the ip of the local computer.
Example
IP to the vagrant server is 192.168.192.192
On my main computer I run the command ssh vagrant#192.168.192.192 and I login with the default password.

Cannot connect to mosquitto broker from local web client on windows

I am trying to connect to mosquitto windows broker service on my machine through javascript. I understand that Paho javascript client connects only through websockets and mosquitto for windows doesn't support websockets unless you build it yourself. My question is that since I am trying to connect to localhost should it matter to have a websockets enabled mqtt broker? Is there any way to connect to a local mqtt server without using websockets through javascript? And is it unsafe to do so or is it fine since I am connecting to a local server itself?
Thanks in advance for the answer and sorry if it sounds lame to you. I am extremely new to this space.
Even when connecting to localhost you still need websockets support to use the paho JavaScript support.
There are some small apps that will set up a separate websocket listener and bridge that to pure native MQTT e.g.
http://hai-ng.blogspot.co.uk/2014/08/setting-up-mqtt-websocket-gateway-with.html

use telnet or ssh in a web application

I am new to web application development and now want to implement an function. Let me describe it:
There is a remote machine or server, I can telnet or ssh to it and run some commands on the server using tools such as Putty or terminal. Now, I want to build a dialog box or input box in my web application, and users can use this box to ssh or telnet to the machine and run commands.
Any comments about this idea? Thanks so much.

socket.io/socket.io.js stuck on (pending) - Node.js

So whenever I check if the /socket.io/socket.io.js file is loaded onto my webpage is says (pending) and after a while (failed) net::ERR_CONNECTION_REFUSED
I've been looking through some other posts and trying some stuff.
I've tried using <script src="/socket.io/socket.io.js"></script>
and <script src="http://127.0.0.1:8080/socket.io/socket.io.js"></script>
My original code includes <script src="http://10.0.0.199:8080/socket.io/socket.io.js"></script> where 10.0.0.199 is my server which is running node.js and mongoDB.
My full code of my server.js file is as follows: (this file starts the socket.io)
var mongo = require('mongodb').MongoClient,
client = require('socket.io').listen(8080).sockets;
console.log('info - socket.io started');
Do not try to import Node JS script on web page
You can not play directly with socket in JS under Web Browser. Currently web browsers support only websockets.
Apparently my firewall somehow managed to block the 8080 port again.
I used iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT -m comment --comment "Socket.io port" to open the port on my firewall but this did not help. I managed to open the port using the GUI on my server.
Thanks everyone, and I hope that this might help someone in the future as this was very confusing.

Node.js on Amazon AWS goes down when Putty SSH is disconnected

I just set up my first Amazon AWS server, with a Node.js installation on it. I run my app, at which point Node says that it's listening on port 3000. However, if I close my laptop, Node.js is no longer reachable through my app. How can I make it run even when I'm not logged in to the server through Putty? As a follow-up question, how can I re-open the Node instance (so that I see the any console.log messages from it) when I log back in to my server?
Thank you!
This is part StackOverflow, part Serverfault question I believe. It sounds like the problem is you're running the node server in the foreground of your SSH session, but you'd rather run it like a service (in the background).
When you exec something like that simple node server, you're running it (by default) in your SSH connection, which ends when your connection terminates from sleeping your computer. Some scripts/programs will run by default in the background, but if you're seeing results in STDOUT (printing to the shell) it is running in the foreground.
Highjacking these answers: Node.js as a background service
Two solutions
*nix solution: http://en.wikipedia.org/wiki/Nohup
Node solution: https://github.com/nodejitsu/forever

Categories