Skip to content
Shiny.NET

Best Practices & FAQ

Always use .Timeout(TimeSpan.FromSeconds(X)) on BLE observables. Android can hang on certain calls if a connection drops mid-operation.

While Shiny handles many known Android BLE issues internally, following these rules will save you from common pitfalls:

# Rule
1 Don’t hold peripheral references across scans unless the device is connected.
2 Don’t scan while connected to a GATT server — avoid overlapping radio operations.
3 Don’t overwhelm the radio. Shiny queues operations internally, but rapid-fire calls still cause issues.
4 Expect GATT 133 errors on connect. Catch exceptions in your observable subscriptions.
5 Expect operations to fault on disconnect. An operation interrupted mid-flight throws a BleException rather than hanging — always handle onError and retry once the peripheral reports Connected again. If your subscription is already gone when the fault arrives, Shiny drops it rather than raising it through TaskScheduler.UnobservedTaskException, so there’s no need to filter BleException out of crash reporting.
6 Keep payloads small. BLE is not designed for large data or JSON — use compact binary formats.
7 Always scan with a Service UUID filter. Unfiltered scans return every BLE device nearby and drain battery.
8 Don’t discover all services & characteristics. Only query the ones you need — full discovery has a real performance cost.