-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SocketIO - Connect failed after Disconnected #14077
Comments
I think it's because cocos2d-x socket.io implementation haven't implemented reconnect even. I don't know how to do it also. I tried adding on "reconnect" event with no success |
Fixed: Update: ZeroHackeR@4cfe139 |
@man2 Yes.. there is no reconnect methods. We got to manually monitor and connect again if it gets disconnected. And there was a bug as above when tried to connect again. |
thanks for the fix.. awesome.. |
Fixes for issue: cocos2d#14077
@pandamicro Please check and merge |
Thanks for the fix, it have been reviewed and merged |
Glad to be a part of this awesome engine ;) |
The pleasure is ours ~ |
When the server disconnects 。 the client response disconnect function. Re-connect Crash。 sioManager.init = function(){ sioManager.disconnect = function(){ this is my code , i don't find where problem>... |
@Super-Man what is your cocos version? make sure your socketio.cpp has the fixes as above... and try to add some delay before calling init... |
@ZeroHackeR I try to disconnect the response received when a record label, indicating disconnected. Then call disconnect (); time to get in the timer status is disconnected, go to init () but the connection again, unsuccessful. this is my code var sioManager = sioManager || {}; // sio init sioManager._sioClient.on("disconnect",sioManager.disconnection); sioManager.disconnection = function(){ In the main scene. schedule function, this.schedule(this.reconnectSio,1); reconnectSio :function(dt){ |
@Super-Man I think, you don't need to call sioManager._sioClient.disconnect() as socket must be already disconnected to reach to "disconnect" event handler. All the best and I'm already using Socket.IO in two of my games and they are working fine. Good Luck Bro! |
@ZeroHackeR |
Here're my codes (not full version) using Cocos 3.8 (with custom socketio.cpp fix as above)
|
@ZeroHackeR OK , i'll check my codes。 thank you ! |
@ZeroHackeR Very helpless! |
function linxuanwei_sio(_uri){ linxuanwei_sio.prototype.connect = function(){ linxuanwei_sio.prototype.reconnect= function(){ After server restarted, cocos crashed too. |
function linxuanwei_sio(_uri){ linxuanwei_sio.prototype.connect = function(){ linxuanwei_sio.prototype.reconnect= function(){ @ZeroHackeR server restarted , crashed! I wrong? |
Thanks for reporting guys... For time being, please try to restart the game if you got disconnected. |
@ZeroHackeR @Super-Man @pandamicro I found the reason of crash, after the server rebooted. when the server stopped, cocos would call method "SIOClientImpl::onClose()", and then, cocos would call method "connect", but method "connect" called method "SIOClient::disconnect()". so bug came , method "SIOClient::socketClosed()" and method "SIOClient::disconnect()" both called method "this->release()" free twice memory. I added a method void SIOClient::disconnectNotRelease(){
} edited method "connect"
_ //c->disconnect(); |
Setup:
Test Flow:
The text was updated successfully, but these errors were encountered: