I'm testing with and unity.

In my localhost (my pc) did walk perfectly but now I got all on my hosting to see how it works online and i have the following problem:

url app online:

I have this loop error:



var express = require('express');
var port = process.env.PORT || 29011;

var app = express();
var http = require('http').Server(app);
var io = require('')(http);

app.use(express.static(__dirname + '/public'));

io.on('connection', function(socket){
    socket.on('chat message', function(message){
        io.emit('chat message', message);

http.listen(port, function(){
    console.log('Express server listening on port ' + port);


var socket = io.connect('');

socket.on('chat message', function(message){
    SendMessage ('ChatSystem', 'GetChatMessage', message);
    console.log("Mensaje recibido del Servidor hacia Unity: " + message);

function UnitySendMessage(message){
    socket.emit('chat message', message);
    console.log("Mensaje de Unity al Servidor: " + message);

Any idea?

Best Solution

In your server code, you should use server.listen(port, ...) and not app.listen(port, ...) because app.listen() creates a new http server and attaches to that, which you do not want because you already have one (server).

Also, in your client code, you should use io.connect(''); instead of io.connect(''); because the server won't know to listen on /UnityApps (because you're not passing a config object (with path set) to the server constructor), even after you've moved the :29011 part to the right place.

Related Question