Rapsssito / react-native-tcp-socket

React Native TCP socket API for Android, iOS & macOS with SSL/TLS support.
MIT License
303 stars 81 forks source link

Android Client crashes when connected Server crashes. #153

Closed cc-steina closed 1 year ago

cc-steina commented 2 years ago

Description

When a server crashes the client is connected to the app will shutdown with a fatal error.

Steps to reproduce

Steps to reproduce the behavior:

  1. Create connection to Server
  2. Let Server ungracefully destroy it self. Or shut down the machine it is running on.
  3. Android app will crash

Or code:

const currentClient = new net.Socket();

let client: ClientConnection | undefined;

client.on('connect', () => {
        onClientConnected!();
    });

    client.on('data', (data) => {
        if (typeof data === 'string') {
            onServerMessage!(data);
        } else {
            onServerMessage!(data.toString());
        }
    });

    client.on('drain', () => {
        onClientDrain!();
    });

    client.on('error', (error) => {
        onClientError!(error);
    });

    client.on('close', (error) => {
        onClientDisconnected!(error);
    });

Client Connection call:

await client.connect(
        {
            port: 8090,
            host: host,
            reuseAddress: true,
        },
        () => {
            onClientConnected(client);
        }
    );

Current behavior

Android App crashes when server is unexpectedly shutting down

Expected behavior

The android app should get an error somewhere that will allow handeling and not crash the entire app.

Screenshots Error caught on the client phone after Server crashes

Relevant information

OS Android
react-native 0.63.2
react-native-tcp-socket 5.6.2
github-actions[bot] commented 2 years ago

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community attention? This issue may be closed if no further activity occurs.