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

Host not reachable error handling #121

Open
sudray opened this issue Aug 16, 2021 · 6 comments
Open

Host not reachable error handling #121

sudray opened this issue Aug 16, 2021 · 6 comments
Labels
bug Something isn't working work-in-progress

Comments

@sudray
Copy link

sudray commented Aug 16, 2021

Description

Hi I have been evaluating your module as an update for some older react-tcp code and it performs well.
Great job and good work in keeping the calls similar to the Node "net"module. Makes for easy use and implementation.

I am an embedded programmer and have decent knowledge of embedded tcp/ip sockets in the micro-controller domain.

My react native app creates multiple tcp clients, all connecting to some hardware and exchanging data.
All events such as connect() / data() / close() / error() ) work perfectly well and I have created and connected up to 30 simultaneous clients with no issues at all in iOS & Android.

Steps to reproduce

If some or all servers are OFF and not reachable on the network, the iOS version tries to connect and then has an error and subsequently the close event destroys the client and our routine tries to reconnect again...and all is well.....

In android ( when some or all servers ore OFF ) an error is called within 3 seconds of the connect() function ( even though the connect timeout is set to 5 seconds or greater ) and then an error followed by close occurs.
Our code is setup to reconnect and tries but eventually after a few minutes the app crashes.

The effect is more pronounced when more client sockets are trying to connect to unreachable servers.
I have even tried adding a 10 second delay after socket.destroy and connecting again, to no avail...

Current behavior

If the server is offline or down or unreachable the app crashes
The error is occurring at java level and i do not have a screenshot right now but will share one asap

Expected behavior

The error() event should fire followed by the close() event

Relevant information

React Native 0.64
Xcode 13
Android studio 2021.1.1

Notes

Would love to hear what the possible issues could be and if any possible solutions suggested.
Will share any further details as required, and would love to sponsor your work ( for basic prioritized bug support )

Cheers !!

sudray

@sudray sudray added the bug Something isn't working label Aug 16, 2021
@Rapsssito
Copy link
Owner

@sudray, I am sorry for your issue. Could you provide a minimal reproducible example code so I can test it in my local setup?

@Mohamed-kassim
Copy link

Mohamed-kassim commented Sep 22, 2021

@sudray, I am sorry for your issue. Could you provide a minimal reproducible example code so I can test it in my local setup?

please clear me if I am wrong this happens on android
I am connecting the client and using the keepalive boolean to be true

const socketClient = TcpSocket.createConnection(
    {
      port: portNumber,
      host: ipAddress,
      timeout: 3000,
    },
    onClientConnected,
  );
  socketClient.setKeepAlive(true, 2000);

if I closed the server app any time, immediately the client raises a close event and this is great
but if disconnect the internet from the server app the client app is still working and even sending data to the server dropped connection is working and the client finds everything is okay
after some time, minutes, or sometimes more, the client raises an error
is this is the expected scneareo?
and if it's how can I detect that the server is down or not reachable from the client, is it related to this issue of host not reachable error handing?

@Mohamed-kassim
Copy link

@Rapsssito Any Information?

@Rapsssito
Copy link
Owner

Rapsssito commented Oct 5, 2021

@Mohamed-kassim, sorry for my late reply. I am working on handling the same errors on iOS and Android. I will close this issue as soon as this is fixed!

@Mohamed-kassim
Copy link

@Rapsssito no problem, currently, I am syning the server manually with interval and waits for ack to detect when it's down as a workaround
https://blog.stephencleary.com/2009/05/detection-of-half-open-dropped.html
hope you can finish this soon, Thanks for your efforts

@siarheipashkevich
Copy link

@Mohamed-kassim could you please share how you solve your problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working work-in-progress
Projects
None yet
Development

No branches or pull requests

4 participants