Skip to content
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

OnDisconnect not getting fired and reconnect even with bShouldAutoConnect = false; #57

cattomic opened this issue Jul 25, 2017 · 3 comments


None yet
2 participants
Copy link

commented Jul 25, 2017

Hi, I have been using this plugin for a while and is awesome, but there are two things I cant get to work:
I successfully bind function with OnConnect:
SIOClientComponent->OnConnected.AddDynamic(this, &UfpsGameInstance::OnClientWsConnect);
where OnClientWsConnect is defined as: UFUNCTION() void OnServerWsConnect(FString SessionId);

but it doesnt work at all with OnDisconnect:
SIOClientComponent->OnDisconnected.AddDynamic(this, &UfpsGameInstance::OnClientWsDisconnect);
where OnClientWsDisconnect is defined as: UFUNCTION() void OnClientWsDisconnect(TEnumAsByte<ESIOConnectionCloseReason> Reason);

SIOClientComponent->OnSocketNamespaceDisconnected.AddDynamic(this, &UfpsGameInstance::OnClientWsDisconnect) doesnt work neither.

And no matter I set SIOClientComponent->bShouldAutoConnect = false; it keeps reconnecting when server is again available and then sends all the messages not delivered.

Can you help me?


This comment has been minimized.

Copy link

commented Jul 25, 2017

You need to set bShouldAutoConnect before begin play happens for it to take effect. e.g. in your parent/owner class constructor. You should also be able to call SIOClientComponent->Disconnect() at any time to stop your component from reconnecting.

As for the bound connections, have you tried the blueprint equivalent versions and confirmed that these work as expected?

Another option is to go down one level and use the FSocketIONative class which the component implements in to forward the events getting fired. But this is a workaround, if you have time, consider making a minimum project which allows for easy replication of the problem.


This comment has been minimized.

Copy link

commented Jul 26, 2017

I have in my GameInstance constructor:
SIOClientComponent = CreateDefaultSubobject<USocketIOClientComponent>(TEXT("SocketIOClientComponent")); SIOClientComponent->bShouldAutoConnect = false;

I have tryed setting it to false even in your USocketIOClientComponent constructor... but it keep reconnecting when the server is available again.

About the disconnected event, I have tryed it in bp too, but I only get the event when I call disconnect, not when I got disconnected, for example, closing my node.js server.

You should also be able to call SIOClientComponent->Disconnect() at any time to stop your component from reconnecting.
Right, but I cant do it if I dont know I lost my connection.

@getnamo getnamo self-assigned this Aug 12, 2017

@getnamo getnamo added the bug label Aug 12, 2017


This comment has been minimized.

Copy link

commented Nov 11, 2017

Fixed in f17df08.

The new architecture has a new callback called OnConnectionProblems. By default the plugin will attempt re-connections an infinite amount of time so OnDisconnect never gets called in the case of a server being closed. You can now detect this state by subscribing to the above function which also gives you details such as time since last connection etc etc.

The other reconnection issue should now also be fixed, re-open the issue if you find that new architecture still has this problem.

@getnamo getnamo closed this Nov 11, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.