Loop with socket.io terminates at the beginning

I'm building this function for upload to the server small tile images. The client builds the tileBuffer and then calls the fireTiles function. Here I would like to build a loop based on the tileBuffer.length. The server will handle the control. So, i emit StartAddTiles and I immediately called back from the server with the AnotherTile event. The debugger shows me I've been called by the server and I see the code going into the socket.on('AnotherTile'... sentence.

The problem is that when the code reaches the AddTile emit function, it stops there and nothing happens. The server does not receive the request and the loop is terminated there.

Where is the error in my code?

 function fireTiles (tileBuffer, mapSelected) {

        var tiles =   tileBuffer.length;
        var tBx = 0;

        try
        {
            var socket = io.connect('http://myweb:8080/');

            socket.emit('StartAddTiles', tiles, mapSelected);   
            socket.on('AnotherTile', function (tlN){
                if (tlN < tiles) {
                    var data = tileBuffer[tlN];  //uso tlN per far comandare il server
                    tBx++; // debug purpose
                    socket.emit('AddTile', mapSelected, data, tBx);
                } else {
                // something went wrong
                    alert('Error calculating tiles');
                    return;
                }
            });
        }
        catch(err)
        {
            document.getElementById('status').innerHTML = err.message;
        }


    } 

Here is the server side:

io.sockets.on('connection', function(client) {
  console.log('Connecting....');
// controls are limited, this is just a beginning

  // Initiate loop
  client.on('StartAddTiles', function(tiles, mapSelected) {
    var mapId = mapSelected;
    mapLoading[mapId] = {  //Create a new Entry in The mapLoading Variable
    tilesToLoad : tiles,
    tilesLoaded : 0
    }
     console.log('Start loading '+mapLoading[mapId].tilesToLoad+' tiles.');
    // Ask for the first tile
    client.emit('AnotherTile', mapLoading[mapId].tilesLoaded);
      //

  });

  // client add new Tile/Tiles
  client.on('addTile', function(mapSelected, data, tBx) {
    var mapId = mapSelected;
    mapLoading[mapId].tilesLoaded = ++1;
    console.log('Adding tile '+mapLoading[mapId].tilesLoaded+' of '+mapLoading[mapId].tilesToLoad+' tBx '+tBx);

    // insert Tile
    db_manager.add_tiles(tileBuffer, function(result) {

        if (mapLoading[mapId].tilesLoaded == mapLoading[mapId].tilesToLoad) {  // full map loaded
        mapLoading[mapId] = "";  //reset the buffer
        client.emit('TilesOk', mapLoading[mapId].tilesLoaded);
        } else {
        console.log('requesting tile num: '+mapLoading[mapId].tilesLoaded);
        client.emit('AnotherTile', mapLoading[mapId].tilesLoaded);
        }
      //

    });
  });

The event names are case sensitive, you should probably use AddTile instead of addTile on the server side too.