BLE - cannot scan after disconnected

I want my device to be able to connect Bluetooth without rebooting or resetting

it works fine when I first connect, but it doesn’t work after that

To make it work as intended
I have to add a few seconds of delay in each step(disconnect, scan, connect)

So rebooting the app result in faster

2 errors occur
error 3300 error 9005 in extension bluetoothLE Disconn…
error 3300 error 9105 in extension bluetoothLE Except…

Could this be a problem of my device(arduinoIDE with esp32)?
or a limitation of BLE?

what should I do?

Hi, i tried something similar where i wanted my app to connect to hc-05 bluetooth circuit connected to an arduino, what i did was after selecting the bluetooth address to connect to, i used the clock component to set an timer:
image
Where label3 contained the address of the bluetooth device i wanted to connect to

I solved

Solution
Add ‘disconnect’ both app and device.

When clicking disconnect, send a ‘disconnect signal’ to the device so that it actively disconnects.

image

String value = pCharacteristic->getValue();
    if (value == "disconnect") {
      uint16_t connId = pServer->getConnId();  // get client ID
      pServer->disconnect(connId);             
      Serial.print("disconnect");
      pCharacteristic->setValue("ready");  // set pCharacteristic to other value or not, disconnect infinitely
    }

Using this way, I reduced the total delay from 10 seconds to about 2 seconds.