Message from @redd

Discord ID: 462138140975693824


2018-06-29 06:04:01 UTC  

that error just means it can't bind to the port. Everything else in your code looks fine to me.
You may run into another error that looks exactly like that - where a port like 8000 doesn't work. Just check there is nothing running on that port before using it

2018-06-29 06:04:55 UTC  

I think my first mistake was trying to do websockets on a shared hosting server.

2018-06-29 06:05:06 UTC  

you can use that

2018-06-29 06:05:18 UTC  

bind the websocket server to the HTTP server

2018-06-29 06:05:28 UTC  

which library are you using?

2018-06-29 06:05:48 UTC  

Socket.io i think

2018-06-29 06:06:10 UTC  

Was trying to follow some tutorial

2018-06-29 06:07:55 UTC  

```js
var express = require('express');
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io')(server);

app.use(express.static(__dirname + '/bower_components'));
app.get('/', function(req, res,next) {
res.sendFile(__dirname + '/index.html');
});

io.on('connection', function(client) {
console.log('Client connected...');

client.on('join', function(data) {
console.log(data);
client.emit('messages', 'Hello from server');
});
});

server.listen(4200, function() {
console.log('Server running...');
}); ```

2018-06-29 06:08:07 UTC  

something like this?

2018-06-29 06:08:48 UTC  

I gtg in like 2 mins lol

2018-06-29 06:09:00 UTC  

Yeah something similar

2018-06-29 06:09:28 UTC  

now that's the server file right?

2018-06-29 06:09:44 UTC  

also i can pick up "tomorrow " if needed

2018-06-29 06:09:47 UTC  

yes

2018-06-29 06:10:04 UTC  

that is an example "app.js" or whatever you want to call it

2018-06-29 06:10:30 UTC  

here is the tutorial I took that example from

2018-06-29 06:10:44 UTC  

and i'd run "node app" from ssh?

2018-06-29 06:11:28 UTC  

if you were ssh'ing into your server, yes

2018-06-29 06:11:54 UTC  

redd ~$ node ./app
Server running...

2018-06-29 06:11:58 UTC  

something like that

2018-06-29 06:12:12 UTC  

pretty sure you don't need the `./` part tho

2018-06-29 06:12:23 UTC  

whatever works ¯\_(ツ)_/¯

2018-06-29 06:12:30 UTC  

and then what would be the client side url

2018-06-29 06:13:00 UTC  

if you are running it on your computer, `http://localhost:4200/`

2018-06-29 06:13:26 UTC  

now I'm stuck cause im on shared hosting

2018-06-29 06:13:36 UTC  

if you are running on a server, `http://<server ip>:4200/`

2018-06-29 06:13:43 UTC  

what do you mean by that?

2018-06-29 06:13:55 UTC  

like, through bluehost

2018-06-29 06:14:15 UTC  

i cant open ports and dont have access to 80 so I dont think i can do it

2018-06-29 06:14:24 UTC  

you can use any port

2018-06-29 06:14:34 UTC  

they have them all closed

2018-06-29 06:14:41 UTC  

?

2018-06-29 06:14:49 UTC  

open a support ticket

2018-06-29 06:14:56 UTC  

you are missing something

2018-06-29 06:15:01 UTC  

wait

2018-06-29 06:15:08 UTC  

do you have root access to the server?

2018-06-29 06:15:13 UTC  

dont think so

2018-06-29 06:15:24 UTC  

try `sudo node app`

2018-06-29 06:15:29 UTC  

then type your password

2018-06-29 06:15:38 UTC  

I really gtg