{"action":"created","issue":{"url":"https://api.github.com/repos/shmuelzon/esp32-ble2mqtt/issues/3","repository_url":"https://api.github.com/repos/shmuelzon/esp32-ble2mqtt","labels_url":"https://api.github.com/repos/shmuelzon/esp32-ble2mqtt/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/shmuelzon/esp32-ble2mqtt/issues/3/comments","events_url":"https://api.github.com/repos/shmuelzon/esp32-ble2mqtt/issues/3/events","html_url":"https://github.com/shmuelzon/esp32-ble2mqtt/issues/3","id":314439487,"number":3,"title":"Stability issues","user":{"login":"DurandA","id":3709037,"avatar_url":"https://avatars2.githubusercontent.com/u/3709037?v=4","gravatar_id":"","url":"https://api.github.com/users/DurandA","html_url":"https://github.com/DurandA","followers_url":"https://api.github.com/users/DurandA/followers","following_url":"https://api.github.com/users/DurandA/following{/other_user}","gists_url":"https://api.github.com/users/DurandA/gists{/gist_id}","starred_url":"https://api.github.com/users/DurandA/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DurandA/subscriptions","organizations_url":"https://api.github.com/users/DurandA/orgs","repos_url":"https://api.github.com/users/DurandA/repos","events_url":"https://api.github.com/users/DurandA/events{/privacy}","received_events_url":"https://api.github.com/users/DurandA/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":17,"created_at":"2018-04-15T18:29:58Z","updated_at":"2018-04-17T17:07:26Z","closed_at":null,"author_association":"NONE","body":"I am testing this gateway using a [Thingy:52](https://www.nordicsemi.com/eng/Products/Nordic-Thingy-52). It contains a bunch of sensors and data is sent using notifications.\r\n\r\nThe gateway acts as expected after connection to the device and works for a few seconds, and then stops publishing MQTT messages.\r\n\r\nI connected the ESP32 to serial to inspect its output. Before stopping sending MQTT messages, it output a few `esp_mqtt: lwmqtt_publish: -1`, which corresponds to a [buffer too short](https://github.com/256dpi/lwmqtt/blob/4ad31c7857a5208b22aca8829355dea6357f1060/include/lwmqtt.h#L13) to the best of my knowledge.\r\n\r\nAfter a few `esp_mqtt: lwmqtt_publish: -1` errors, the log look like this:\r\n```\r\nE (234658) esp_mqtt: lwmqtt_publish: -1\r\nE (235938) BT: bta_gattc_conn_cback() - cif=3 connected=0 conn_id=3 reason=0x0008\r\nI (235948) BLE: Connection closed, reason = 0x8\r\nI (235948) BLE2MQTT: Disconnected from device: d9:60:eb:5f:df:e3\r\nE (248718) BT: bta_gattc_conn_cback() - cif=3 connected=0 conn_id=259 reason=0x0100\r\nE (248718) BT: p_conn is NULL in bta_gattc_conn_cback\r\n\r\nE (248728) BLE: Open failed, status = 0x85\r\nI (248748) BLE2MQTT: Discovered BLE device: d9:60:eb:5f:df:e5, connecting\r\nE (278758) BT: bta_gattc_conn_cback() - cif=3 connected=0 conn_id=3 reason=0x0100\r\n```\r\n\r\nThe Thingy:52 sends a lot of notifications–a few dozens per second. Could it be related to a buffer overflow because the ESP32 can't send MQTT messages as fast as it receives notifications?"},"comment":{"url":"https://api.github.com/repos/shmuelzon/esp32-ble2mqtt/issues/comments/382069687","html_url":"https://github.com/shmuelzon/esp32-ble2mqtt/issues/3#issuecomment-382069687","issue_url":"https://api.github.com/repos/shmuelzon/esp32-ble2mqtt/issues/3","id":382069687,"user":{"login":"shmuelzon","id":2786045,"avatar_url":"https://avatars2.githubusercontent.com/u/2786045?v=4","gravatar_id":"","url":"https://api.github.com/users/shmuelzon","html_url":"https://github.com/shmuelzon","followers_url":"https://api.github.com/users/shmuelzon/followers","following_url":"https://api.github.com/users/shmuelzon/following{/other_user}","gists_url":"https://api.github.com/users/shmuelzon/gists{/gist_id}","starred_url":"https://api.github.com/users/shmuelzon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/shmuelzon/subscriptions","organizations_url":"https://api.github.com/users/shmuelzon/orgs","repos_url":"https://api.github.com/users/shmuelzon/repos","events_url":"https://api.github.com/users/shmuelzon/events{/privacy}","received_events_url":"https://api.github.com/users/shmuelzon/received_events","type":"User","site_admin":false},"created_at":"2018-04-17T17:07:26Z","updated_at":"2018-04-17T17:07:26Z","author_association":"OWNER","body":"I believe that the GATTC API queues read/notification requests. Perhaps if a lot of them are created before the queue has a change to be emptied it can cause the issue you're seeing. Before, the BT task was on CPU 0 so it could remove requests from the queue while the app on CPU 1 handles the new characteristics it discovers. Since the BT task is now on CPU 1 as well, it doesn't get that chance.\r\n\r\nI don't have a thingy:52, but I do have a TI SensorTag. I don't know exactly how many characteristics it serves but it should be more than the devices I use daily. I'll try it out and let you know if I find anything interesting."}}
{"actor":{"display_login":"shmuelzon"}}