UnitySocketIO
UnitySocketIO copied to clipboard
What version of socket.io do I need?
I am struggling to get this working, I only received "handshake authorized" in my server, and socket opened event does not fire.
Server:
io.sockets.on('connection', function(socket) {
console.log("-- Socket connected!");
socket.emit("message", "Welcome fagget!");
});
Unity client:
client = new Client("http://localhost:1337");
client.Opened += SocketOpened;
client.Message += SocketMessage;
client.SocketConnectionClosed += SocketConnectionClosed;
client.Error += SocketError;
Debug.Log("Client set up, connecting..");
client.On("message", data =>
{
Debug.Log("Message received!");
});
client.Connect();
I can confirm that after calling .Connect() on the client, a handshake does occur, but the client shows as connecting still and never seems to progress.
@rainabba we ended up using raw TCP sockets instead.
My issue was insanely silly. When my server bound to "localhost" (Both my Hapi and Express versions), it was apparently binding to an interface that wasn't connected to the same "localhost" as my Unity app. Even when I updated my unity app to connect to my local ip, it still refused to work. When I bound my Socket.IO server to my IP, it suddenly worked which led to me to find that i had vmware virtual interfaces (for Workstation) that were interfering and when I disabled them OR bound my server to a particular IP, the client would then connect so for me this turned out to be a Windows/Networking/Node issue which I've not seen before even though my regular workstation also has vmware workstation on it.