Answer the question
In order to leave comments, you need to log in
Unable to connect Socket.io, where is the error?
I connect socket.oi. It does not display any errors, but it does not write anything to the console either, here is the code, the page files are signed. The layout.jade file is cross-cutting for all pages.
app.js
var express = require('express'),
app = require('express')(),
http = require('http').Server(app),
io = require('socket.io')(http),
start = require('./routes/index.js');
app.use('/', start);
io.on('connection', function(socket){
console.log('a user connected');
socket.on('disconnect', function(){
console.log('user disconnected');
});
});
var server = app.listen(3000, function () {
var host = server.address().address;
var port = server.address().port;
});
module.exports = app;
doctype html
html(lang="en")
head
script(type="text/javascript" src="https://cdn.socket.io/socket.io-1.4.3.js")
script.
var socket = io();
body
block content
Answer the question
In order to leave comments, you need to log in
It's not entirely clear why you are using socketio herevar socket = io('ws://example.ru:3000')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question