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

Hadle event for true recconect #24

Open
devprog777 opened this issue Jul 16, 2024 · 1 comment
Open

Hadle event for true recconect #24

devprog777 opened this issue Jul 16, 2024 · 1 comment
Labels
Need more context Need more context

Comments

@devprog777
Copy link

If reccont is true you must handle any Error Exception and Logic for any errro Example:

  1. if connection initialized and server up down

  2. if server up down and you initialized connection
    ` .catchError((error) {
    if (error is SocketException) {
    // Обработка работает
    if(error.osError!.errorCode == 110){
    // SocketException: OS Error: Connection timed out, errno = 110 If server connection close
    // Логика для обработки ошибки 110 сервер не доступен, при инницилизации подключения
    // Функция для переподклбчения
    // Logic for this error
    print('Ошибка поймана: ${error.osError!.errorCode}');
    }

    } else {
    // if connection initialized and server up down - I/flutter (14205): Exception: ClientException: Connection closed before full header was received, uri=http://url:3000/iot?host=abfarm-us-west1-c-0089
    print('Exception: $error');

    }
    })

    .catchError((e) {
    // Количесвто возможных ошибок (2) не включая когда отключают adapter wifi или eth это 3
    // Еще проверить когда отключают adapter wifi или eth это 3
    // 1. Когда подключение инициированно, после отключения сервера ошибка ->
    // - I/flutter (14205): Exception: ClientException: Connection closed before full header was received, uri=http://url:3000/iot?host=abfarm-us-west1-c-0089
    // 2. Когда сервер недоступен при инницирование подключение
    // - Exception: ClientException with SocketException: Connection timed out (OS Error: Connection timed out, errno = 110), address = url, port = 33678, uri=http://url:3000/iot?host=abfarm-us-west1-c-0089

    print('Exception: $e');
    // _attemptReconnectIfNeeded();
    });`

@Imgkl
Copy link
Owner

Imgkl commented Jul 18, 2024

@devprog777, Thanks for filing this issue. I want to ensure I fully understand your concern. Is this the issue you are encountering?

When reccont is set to true, please ensure proper error handling for all exceptions and logic errors. For example:

- Handle cases where the connection is initialized but the server goes down.
- Handle scenarios where the server is down when you attempt to initialize a connection.

The code should properly catch and manage exceptions like SocketException with an error code of 110, indicating a timeout, which suggests the server is unavailable. Implement logic for reconnection in these cases. Additionally, address the scenario where the client's connection is closed before the full header is received, identifying it as a different error scenario

@Imgkl Imgkl added the Need more context Need more context label Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Need more context Need more context
Projects
None yet
Development

No branches or pull requests

2 participants