user1502301
user1502301

Reputation: 565

Unity3d and Sockets.IO won't handshake

I am using https://github.com/kaistseo/UnitySocketIO-WebSocketSharp to enable Unity3D to talk to a Node.JS Socket.IO server. However, it errors out during the handshake with

socket Error: Error initializing handshake with server

Client code:

    SocketIOClient.Client socket;

// Use this for initialization
void Start () {
    socket = new SocketIOClient.Client("http://server:80/");
    socket.On("connect", (fn) => {
        Debug.Log ("connect - socket");

        Dictionary<string, string> args = new Dictionary<string, string>();
        args.Add("msg", "what's up?");
        socket.Emit("SEND", args);
    });
    socket.On("RECV", (data) => {
        Debug.Log (data.Json.ToJsonString());
    });
    socket.Error += (sender, e) => {
        Debug.Log ("socket Error: " + e.Message.ToString ());
    };
    socket.Connect();
}

On the server side,

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

serv = app.listen(port);                                        
var sio = io.listen(serv);
sio.on('connection', function(socket){
   console.log('a user connected');
});

The server side code works fine if I connect to it with a Javascript sockets.io client. Anyone have luck using this to connect to a sockets.io server?

Thanks!

Upvotes: 1

Views: 2457

Answers (1)

user1502301
user1502301

Reputation: 565

RikkusRukkus: If you're using socket.io 1.0 (released May 28), try switching to 0.9.x. The linked repo was last updated on the 11th of april. 1.0 has substantial changes under the hood so the client libraries are probably not interchangeable.

Upvotes: 1

Related Questions