You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
http.listen(3000, function(){
console.log('listening on *:3000');
});
We'll need an index.html file to serve, create a new file called index.html and enter the following in it:
<title>Hello world</title>
Hello world
To test if this works, go to your terminal and run this app using
Hello there I'm working with:
Ubutu 14.04
Express 4.10.2
Socket.io 1.3.7
Vagrant
Port fowarding :8001 to Box :80
Port fowarding :8002 to Box :3000
This is my App.js
var express = require('express');
var app = express();
var server = app.listen(3000);
var io = require('socket.io').listen(server);
var http = require('http');
io.on('connection', function(socket){
console.log('a user connected');
socket.on('disconnect', function(){
console.log('user disconnected');
});
});
and this is my index.html
<!doctype html>
<title>Socket.IO chat</title> <style> \* { margin: 0; padding: 0; box-sizing: border-box; } body { font: 13px Helvetica, Arial; } form { background: #000; padding: 3px; position: fixed; bottom: 0; width: 100%; } form input { border: 0; padding: 10px; width: 90%; margin-right: .5%; } form button { width: 9%; background: rgb(130, 224, 255); border: none; padding: 10px; } #messages { list-style-type: none; margin: 0; padding: 0; } #messages li { padding: 5px 10px; } #messages li:nth-child(odd) { background: #eee; } </style>Send <script src="https://cdn.socket.io/socket.io-1.3.7.js"></script> <script src="http://code.jquery.com/jquery-1.11.1.js"></script> <script> var socket = io.connect(); </script>
then when I open in the browser the index page I get:
Failed to load resource: the server responded with a status of 404 (Not Found)
http://127.0.0.1:8001/socket.io/?EIO=3&transport=polling&t=1451934295598-10
any idea how to solve it?
The text was updated successfully, but these errors were encountered: