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

Can not connect to my AWS hosted Thingsboard Server using the mobile app #164

Closed
valixkaldor opened this issue Oct 4, 2024 · 9 comments
Closed

Comments

@valixkaldor
Copy link

The app is stuck before the login screen, with the thing board logo animation going in circles.
I changed my endpoint to point to the server and i can access it via pc, however not with the flutter app.

I/flutter (30307): dio response ThingsboardError: message: [400: ], errorCode: 31, status: 400
I/flutter (30307): #0 toThingsboardError (package:thingsboard_pe_client/src/error/_thingsboard_error_handler_io.dart:89:18)
I/flutter (30307): #1 HttpInterceptor.onError (package:thingsboard_pe_client/src/interceptor/http_interceptor.dart:104:19)
I/flutter (30307): #2 QueuedInterceptor._handleQueue (package:dio/src/interceptor.dart:401:17)
I/flutter (30307): #3 QueuedInterceptor._handleError (package:dio/src/interceptor.dart:377:5)
I/flutter (30307): #4 DioMixin.fetch.errorInterceptorWrapper..handleError (package:dio/src/dio_mixin.dart:429:22)
I/flutter (30307): #5 new Future. (dart:async/future.dart:256:37)
I/flutter (30307): #6 Timer._createTimer. (dart:async-patch/timer_patch.dart:18:15)
I/flutter (30307): #7 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
I/flutter (30307): #8 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
I/flutter (30307): #9 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
I/flutter (30307): ERROR ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (30307): ERROR │ ThingsboardError: message: [400: ], errorCode: 31, status: 400
I/flutter (30307): ERROR │ #0 toThingsboardError (package:thingsboard_pe_client/src/error/_thingsboard_error_handler_io.dart:89:18)
I/flutter (30307): ERROR │ #1 HttpInterceptor.onError (package:thingsboard_pe_client/src/interceptor/http_interceptor.dart:104:19)
I/flutter (30307): ERROR │ #2 QueuedInterceptor._handleQueue (package:dio/src/interceptor.dart:401:17)
I/flutter (30307): ERROR │ #3 QueuedInterceptor._handleError (package:dio/src/interceptor.dart:377:5)
I/flutter (30307): ERROR │ #4 DioMixin.fetch.errorInterceptorWrapper..handleError (package:dio/src/dio_mixin.dart:429:22)
I/flutter (30307): ERROR │ #5 new Future. (dart:async/future.dart:256:37)
I/flutter (30307): ERROR │ #6 Timer._createTimer. (dart:async-patch/timer_patch.dart:18:15)
I/flutter (30307): ERROR │ #7 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
I/flutter (30307): ERROR │ #8 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
I/flutter (30307): ERROR │ #9 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
I/flutter (30307): ERROR │
I/flutter (30307): ERROR ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (30307): ERROR │ ⛔ TbContext.onUserLoaded: ThingsboardError: message: [400: ], errorCode: 31, status: 400
I/flutter (30307): ERROR │ ⛔ #0 toThingsboardError (package:thingsboard_pe_client/src/error/_thingsboard_error_handler_io.dart:89:18)
I/flutter (30307): ERROR │ ⛔ #1 HttpInterceptor.onError (package:thingsboard_pe_client/src/interceptor/http_interceptor.dart:104:19)
I/flutter (30307): ERROR │ ⛔ #2 QueuedInterceptor._handleQueue (package:dio/src/interceptor.dart:401:17)
I/flutter (30307): ERROR │ ⛔ #3 QueuedInterceptor._handleError (package:dio/src/interceptor.dart:377:5)
I/flutter (30307): ERROR │ ⛔ #4 DioMixin.fetch.errorInterceptorWrapper..handleError (package:dio/src/dio_mixin.dart:429:22)
I/flutter (30307): ERROR │ ⛔ #5 new Future. (dart:async/future.dart:256:37)
I/flutter (30307): ERROR │ ⛔ #6 Timer._createTimer. (dart:async-patch/timer_patch.dart:18:15)
I/flutter (30307): ERROR │ ⛔ #7 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
I/flutter (30307): ERROR │ ⛔ #8 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
I/flutter (30307): ERROR │ ⛔ #9 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
I/flutter (30307): ERROR │ ⛔
I/flutter (30307): ERROR └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (30307): DEBUG ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (30307): DEBUG │ 🐛 LocalDatabaseService::getItem(initialAppLink)
I/flutter (30307): DEBUG └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (30307): DEBUG ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (30307): DEBUG │ 🐛 TbContext: On load finished.
I/flutter (30307): DEBUG └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
I/flutter (30307): ERROR ┌───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

I/flutter (30307): ERROR │ ThingsboardError: message: [400: ], errorCode: 31, status: 400
I/flutter (30307): ERROR │ #0 toThingsboardError (package:thingsboard_pe_client/src/error/_thingsboard_error_handler_io.dart:89:18)
I/flutter (30307): ERROR │ #1 HttpInterceptor.onError (package:thingsboard_pe_client/src/interceptor/http_interceptor.dart:104:19)
I/flutter (30307): ERROR │ #2 QueuedInterceptor._handleQueue (package:dio/src/interceptor.dart:401:17)
I/flutter (30307): ERROR │ #3 QueuedInterceptor._handleError (package:dio/src/interceptor.dart:377:5)
I/flutter (30307): ERROR │ #4 DioMixin.fetch.errorInterceptorWrapper..handleError (package:dio/src/dio_mixin.dart:429:22)
I/flutter (30307): ERROR │ #5 new Future. (dart:async/future.dart:256:37)
I/flutter (30307): ERROR │ #6 Timer._createTimer. (dart:async-patch/timer_patch.dart:18:15)
I/flutter (30307): ERROR │ #7 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
I/flutter (30307): ERROR │ #8 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
I/flutter (30307): ERROR │ #9 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
I/flutter (30307): ERROR │
I/flutter (30307): ERROR ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (30307): ERROR │ #0 toThingsboardError (package:thingsboard_pe_client/src/error/_thingsboard_error_handler_io.dart:89:18)
I/flutter (30307): ERROR │ #1 HttpInterceptor.onError (package:thingsboard_pe_client/src/interceptor/http_interceptor.dart:104:19)
I/flutter (30307): ERROR │ #2 QueuedInterceptor._handleQueue (package:dio/src/interceptor.dart:401:17)
I/flutter (30307): ERROR │ #3 QueuedInterceptor._handleError (package:dio/src/interceptor.dart:377:5)
I/flutter (30307): ERROR │ #4 DioMixin.fetch.errorInterceptorWrapper..handleError (package:dio/src/dio_mixin.dart:429:22)
I/flutter (30307): ERROR │ #5 new Future. (dart:async/future.dart:256:37)
I/flutter (30307): ERROR │ #6 Timer._createTimer. (dart:async-patch/timer_patch.dart:18:15)
I/flutter (30307): ERROR │ #7 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
I/flutter (30307): ERROR ├┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄┄
I/flutter (30307): ERROR │ ⛔ onError
I/flutter (30307): ERROR └───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
E/flutter (30307): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: 'package:flutter/src/material/scaffold.dart': Failed assertion: line 295 pos 7: '_scaffolds.isNotEmpty': ScaffoldMessenger.showSnackBar was called, but there are currently no descendant Scaffolds to present to.
E/flutter (30307): #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)
E/flutter (30307): #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)
E/flutter (30307): #2 ScaffoldMessengerState.showSnackBar (package:flutter/src/material/scaffold.dart:295:7)
E/flutter (30307): #3 TbContext.showNotification (package:thingsboard_app/core/context/tb_context.dart:281:32)
E/flutter (30307): #4 TbContext.showErrorNotification (package:thingsboard_app/core/context/tb_context.dart:230:5)
E/flutter (30307): #5 TbContext.onError (package:thingsboard_app/core/context/tb_context.dart:226:5)
E/flutter (30307): #6 ThingsboardClient._onError. (package:thingsboard_pe_client/src/thingsboard_client_base.dart:218:34)
E/flutter (30307): #7 new Future. (dart:async/future.dart:256:37)
E/flutter (30307): #8 Timer._createTimer. (dart:async-patch/timer_patch.dart:18:15)
E/flutter (30307): #9 _Timer._runTimers (dart:isolate-patch/timer_impl.dart:398:19)
E/flutter (30307): #10 _Timer._handleMessage (dart:isolate-patch/timer_impl.dart:429:5)
E/flutter (30307): #11 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
E/flutter (30307):

@ybeshkarov
Copy link
Contributor

Hello,

Your server is CE or PE?

@valixkaldor
Copy link
Author

PE

@ybeshkarov
Copy link
Contributor

I see a lot of 400 errors in your log output. I'm not exactly sure what the issue is, as I can't view the specific APIs related to the 400 errors. However, it seems there may be an issue with the ThingsBoard/mobile app version, or something else might be causing the problem.

@pgirgis
Copy link

pgirgis commented Oct 5, 2024

I have the same issue when I upgraded to 3.8 - what thingsboard server version are you running?

@valixkaldor
Copy link
Author

@pgirgis my thingsboard version is 3.6.4.

@valixkaldor
Copy link
Author

valixkaldor commented Oct 7, 2024

@ybeshkarov
I have two servers with thingsboard installed. The temporary one connects perfectly however my AWS instance, which i plan to deploy on, will not connect.
I have attempted to use 1.2.0 and 1.3.0 versions of the PE app.
My server uses thingsboard 3.6.4.

This is an image of what happens when i run the app on a clean build of thingsboard pe app.
Please note: my server is HTTPS but i also tried to connect to it using HTTP with no luck.
1728282107306

Edit: Is there a way to add my ssl certificates to the app in order to ensure that the handshake occurs

@ybeshkarov
Copy link
Contributor

This is an issue with your SSL certificate. Ideally, you need to fix the certificate issue to ensure security, but you can bypass it as well.

Inside the dart_thingsboard_pe_client
Open lib/src/thingsboard_client_base.dart
Find all places where the Dio() instance was created
and add

import 'package:dio/io.dart';
import 'dart:io';

.....

final dio = Dio();
(dio.httpClientAdapter as DefaultHttpClientAdapter).onHttpClientCreate =
        (HttpClient client) {
      client.badCertificateCallback =
          (X509Certificate cert, String host, int port) => true;
      return client;
    };

@valixkaldor
Copy link
Author

Thanks. I got it to work on android.

Just out of curiosity, does thingsboard require the entire SSL chain to be signed.
Our AWS server is signed by a ca, however the person who set it up did not add the rest of the signatures in the chain.
Curious that the app doesn't work while the webrowser shows the site as being secure.

@ybeshkarov
Copy link
Contributor

The core issue ended up being that the server did not provide the full certificate chain but only the leaf certificate. Some browsers hides this kinds of issues if the browser have seen the intermediate certificate somewhere else. So just because things works in the browser, it does not means the server is actually providing enough information for other TLS clients to verify the certificate chain.

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

3 participants