F
F
Flasher2016-01-21 11:14:16
JavaScript
Flasher, 2016-01-21 11:14:16

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;

layout.jade
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

1 answer(s)
A
Artur Aralin, 2016-01-21
@ArturAralin

It's not entirely clear why you are using socketio here
var socket = io('ws://example.ru:3000')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question