hashtagchris / DotNet-BlueZ

A quick and dirty library for BlueZ's D-Bus APIs. Focus is on Bluetooth Low Energy APIs.
Apache License 2.0
104 stars 37 forks source link

Lib excepts unexpectedly when retrieving adapter.GetDevicesAsync #16

Open martienpoels-bank2loyalty opened 3 years ago

martienpoels-bank2loyalty commented 3 years ago

Hi Guys,

First of all happy new-year and have a healthy and wonderful 2021!

Im using your library in a bluetooth implementation for a dedicated device (running on a raspberry) bluez version 5.50 I'm not supplying an eventhandler before calling Adapter.StartDiscoveryAsync() as I only use the GetDevicesAsync when I want to see devices.

When calling Adapter.GetDevicesAsync my application crashes after been running for a few days with the following exception Hope someone can fix this!

Unhandled exception. Unhandled exception. Unhandled exception. Unhandled exception. Tmds.DBus.DBusException: org.freedesktop.DBus.Error.LimitsExceeded: Connection ":1.127" is not allowed to add more match rules (increase limits in configuration file if required; max_match_rules_per_connection=512) at Tmds.DBus.DBusConnection.CallMethodAsync(Message msg, Boolean checkConnected, Boolean checkReplyType) at Tmds.DBus.DBusConnection.WatchSignalAsync(ObjectPath path, String interface, String signalName, SignalHandler handler) at Tmds.DBus.Connection.WatchSignalAsync(ObjectPath path, String interface, String signalName, SignalHandler handler) at Tmds.DBus.CodeGen.DBusObjectProxy.WatchNonVoidSignalAsync[T](String iface, String member, Action1 error, Action1 action, ReadMethodDelegate1 readValue, Boolean isPropertiesChanged) at HashtagChris.DotNetBlueZ.Device.CreateAsync(IDevice1 proxy) at HashtagChris.DotNetBlueZ.Adapter.OnDeviceAdded(ValueTuple2 args) at System.Threading.Tasks.Task.<>c.b140_1(Object state) at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute() at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()Tmds.DBus.DBusException: org.freedesktop.DBus.Error.LimitsExceeded: Connection ":1.127" is not allowed to add more match rules (increase limits in configuration file if required; max_match_rules_per_connection=512) at Tmds.DBus.DBusConnection.CallMethodAsync(Message msg, Boolean checkConnected, Boolean checkReplyType) at Tmds.DBus.DBusConnection.WatchSignalAsync(ObjectPath path, String interface, String signalName, SignalHandler handler) at Tmds.DBus.Connection.WatchSignalAsync(ObjectPath path, String interface, String signalName, SignalHandler handler) at Tmds.DBus.CodeGen.DBusObjectProxy.WatchNonVoidSignalAsync[T](String iface, String member, Action1 error, Action1 action, ReadMethodDelegate1 readValue, Boolean isPropertiesChanged) at HashtagChris.DotNetBlueZ.Device.CreateAsync(IDevice1 proxy) at HashtagChris.DotNetBlueZ.Adapter.OnDeviceAdded(ValueTuple2 args) at System.Threading.Tasks.Task.<>c.b140_1(Object state) at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute() at System.Threading.ThreadPoolWorkQueue.Dispatch() at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()

Aborted

KyryloAntoshyn commented 3 years ago

I can confirm that this issue occurs. The same happens on my RPi. image

martienpoels-bank2loyalty commented 3 years ago

I have worked around this issue to not leave the scan mode running for longer than a few minutes max. Have not seen it happen since. But the problem is definitely still there and I agree if you leave scanning open this should not happen.

KyryloAntoshyn commented 3 years ago

For me it crashes after 5 seconds :(