Reputation: 10046
I get 404 on urls like this: http://localhost.dev/socket.io/?EIO=3&transport=polling&t=1411749802784-54
SOCKET IO VERSION: 1.x
APP.JS
var express = require("express"),
app = express(),
server = require('http').createServer(app),
io = require('socket.io').listen(server),
server.listen(8080);
app.get('/', function(req,res){
console.log('started');
});
//Receive message
io.sockets.on('connection',function(socket){
socket.on('send message',function(data){
//Send message out
io.sockets.emit('new message',data);
});
});
So I have my website which is running on port 80
and nodejs on port 8080
and I include socket.io js file like this: <script src="http://localhost.dev:8080/socket.io/socket.io.js"></script>
and I can open the socket.io.js
file in a new tab, but I guess this has something to do with the new version, I am just getting started with node.
//LE
$(document).ready(function(){
//Socket.io
var socket = io.connect();
//Form
var $messageForm = $('#chatForm');
var $messageFormInput = $messageForm.find('#messageText');
var $chat = $('.chat');
//Bind submit form
$messageForm.submit(function(e){
e.preventDefault();
socket.emit('send message',$messageFormInput.val());
//Clear input
$messageFormInput.val('');
});
//Receive message
socket.on('new message',function(data){
$chat.append(data);
});
});
Does anyone know how can I fix this?
Upvotes: 2
Views: 1538