nhn / socket.io-client-unity3d

socket.io-Client for Unity3D, which is compatible with socket.io v1.x
Other
167 stars 42 forks source link

problem in reconnecting to socketio #40

Open MahdiRashidi2001 opened 4 years ago

MahdiRashidi2001 commented 4 years ago

hi, I used this plugin ( dev branch and socket io version is 2) for connecting my game to socket io and handling Listeners and Emit. so when I disconnect to the server my connection has closed but when i want to reconnect to the server in runtime after disconnecting , i think it cant connect to server correctly.

this is my connection script for this :

socketConnection = Socket.Connect(socketUrl);
            socketConnection.On(SystemEvents.connectError , (Exception e) => {
                Debug.Log("Socket.io Connection Error: " + e.ToString());
                Socket.Reconnect(socketConnection);
            });
            socketConnection.On(SystemEvents.connect, () =>
            {
                Debug.Log("Connected To Server");

            });
            socketConnection.On(SystemEvents.reconnect, (int reconnectAttempt) =>
            {
                Debug.Log("Reconnecting : " + reconnectAttempt);
            });
            socketConnection.On(SystemEvents.disconnect, () =>
            {
                Debug.Log("Connection is Closed");
            });

f.e when i connect to server for the first time i have this logs

[Singleton] An instance of socket.io.SocketManager is needed in the scene, so '(singleton) socket.io.SocketManager
socket.io => ws://localhost:6500/socket.io/?EIO=3&transport=websocket&sid=399_XTZwOOSCQmckAACk probed~
socket.io => ws://localhost:6500/socket.io/?EIO=3&transport=websocket&sid=399_XTZwOOSCQmckAACk ping~
socket.io => ws://localhost:6500/socket.io/?EIO=3&transport=websocket&sid=399_XTZwOOSCQmckAACk pong~
connected to server

but when i want to connect for the seccond time in runtime i just have this

socket.io => ws://localhost:6500/socket.io/?EIO=3&transport=websocket&sid=399_XTZwOOSCQmckAACk probed~

and i should mention this that i test Reconnect after an initial connection failure #34 issue and it couldnt help me

please check it and help me.

MahdiRashidi2001 commented 4 years ago

can someone help me with this? it is urgent for me thanks