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

How to keep the connections always live? #2

Open
ot-repo opened this issue Dec 2, 2022 · 3 comments
Open

How to keep the connections always live? #2

ot-repo opened this issue Dec 2, 2022 · 3 comments

Comments

@ot-repo
Copy link

ot-repo commented Dec 2, 2022

Hello Team,

I have the following question.

For an app currently I am building, all the devices on the same WIFI must connect to each other. So every device has a server and many clients to other devices. if a device lost the connections to the other devices because of any reason, I need to reestablish the connection as soon as it's possible. The other devices should be able to connect to this device, as well.

What's the best way to achieve this? Any code sample or any advice is highly appreciated.

Kind Regards
Can

@sourcecaster
Copy link
Owner

Is that what you need?
bool autoReconnect - automatically reconnect when connection is lost, true by default;

@ot-repo
Copy link
Author

ot-repo commented Dec 3, 2022

Thank you for quick response.

I hoped that it solves my problem, too. However, when I switch a device offline and wait for some time and then I go back online again, the client sockets on that device reconnects as expected. However the client sockets on other devices do not reconnect to this device. When I broadcast something from this device to other devices, they will not receive the message.

Hope I could explain it properly, if not, please let me know.

Regards

@sourcecaster
Copy link
Owner

Okay, I have some questions to clarify the situations:
Do you use TCP sockets or WebSockets?
Does server closes socket connections when goes offline?
How exactly do you switch device offline, programmatically or just power off?

A see one obvious solution here: implement some kind of ping request from clients and specify queryTimeout parameter. But may bee there is some easier solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants