1

So I built an app that runs a socket server on port 4000. This is the main part of the server (I've removed redundant functions to the question)

var express = require('express');
var config = require('./config');
var https = require('https');
var client = require('./redis/client');
var socketio = require('./data/socket');

var app = express();


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

app.set('port', config.PORT);

var server = app.listen(app.get('port'), function() {
  console.log('Listening on port ' + server.address().port);
});

var io = socketio.listen(server);

var users = io.on('connection', function(socket) {
  var user;
  console.log("connected")
}

On the client I have the following (also removed redundant handlers, etc):

  var socket: SocketIOClient!

  init() {
    socket = SocketIOClient(socketURL: "http://localhost:4000")
    setupHandlers()
    socket.connect()
  }

  func setupHandlers() {
    socket.on("connect") {
      data, ack in
      print("connected")
      self.socket.emit("addUser", self.app.data._id)
    }
  }

This was working. Then I created a new version of the project and exported this code and it didn't work. So I ran my older version that was working and low and behold that was also not working.

I've been spending days trying to find out why, altering code, testing, blablabla and have come out with nothing.

My only guess now is that maybe an xcode update or something else has changed some hidden file somewhere or something that is preventing connection from the app to the server...

If anyone has any idea of what could be the problem I would be forever grateful!!

w1zard
  • 33
  • 4
  • [http://stackoverflow.com/a/33408323/3441734](http://stackoverflow.com/a/33408323/3441734) try to read the answer there. – user3441734 Nov 01 '15 at 21:46

0 Answers0