UWP Bluetooth ConnectAsync error to Raspberry Pi. Element not found


I'm making a Windows UWP app that uses RFCOMM to communicate to a Raspberry Pi. Both my Windows laptop and Raspberry Pi are already connected and paired (manually). I know the bluetooth address of the Raspberry Pi and the channel it's using and these values are hardcoded into the parameters for ConnectAsync(...).

When ConnectAsync(...) is called, the Raspberry Pi does receive a connection and it prints the line "accepted connection from ('Windows bluetooth address', 1). However, the exception "An exception of type 'System.Exception' occurred in mscorlib.ni.dll but was not handled in user code. Additional information: Element not found. (Exception from HRESULT: 0x80070490)" happens at where ConnectAsync(...) is called, and the message is never delivered to the Raspberry Pi.

Windows Code (as the client, trying to send message to the Raspberry Pi):

StreamSocket socket = new StreamSocket(); await socket.ConnectAsync(new HostName(bluetoothAddress), "1"); // the format of bluetoothAddress is 'AB:CD:AB:CD:AB:CD' Stream streamOut = socket.OutputStream.AsStreamForWrite(); StreamWriter writer = new StreamWriter(streamOut); await writer.WriteLineAsync(message); await writer.FlushAsync();

Raspberry Pi (as Python Server):

import bluetooth server_sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM ) port = 1 server_sock.bind(("",port)) server_sock.listen(1) client_sock,address = server_sock.accept() print("Accepted connection from ",address) data = client_sock.recv(1024) print("received [%s]" % data)

When I replace the "1" in ConnectAsync(...) with bluetoothAddress, a 'Value does not fall within the expected range' exception appears.


The second parameter "remoteServiceName" of the method socket.ConnectAsync() should be RfcommDeviceService.ConnectionServiceName.

For more information you can reference <a href="https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/BluetoothRfcommChat" rel="nofollow">Bluetooth RFCOMM chat sample</a>.


  • Cassandra eats memory
  • Why does this LinQ query not like chars?
  • Reading old clipboard data in new program version in C#
  • How to to parallelize the matrix transpose?
  • DNS of the server where ASP.NET application is run
  • Windows 10 Bluetooth Gatt Client ValueChanged issue
  • Functions returning a const value [duplicate]
  • wxWidgets: Detecting click event on custom controls
  • How to limit cursor movement in WPF based app?
  • How to filter entities that are deleted using linq to entities
  • Change Divider Color Android DatePicker Dialog
  • Google OAuth2 for an web application hosted behind NAT (intranet server without public IP)
  • phpmailer - How to verify a sent email arrived at its destination
  • Create a multiple screen android application
  • Available space left on drive - WinAPI - Windows CE
  • Translating C# to PowerShell in InterIMAP
  • Authentication failed with Azure Active Directory in Windows Phone
  • Undefined references when compiling gSOAP client
  • Very simple C++ DLL that can be called from .net
  • why do I get the error when installing the gem 'pg'? [duplicate]
  • Lost migrations and Azure database is now out of sync
  • ilmerge with a PFX file
  • Why value captured by reference in lambda is broken? [duplicate]
  • Using $this when not in object context
  • Master page gives error
  • Launch Runnable Jar from Web Start
  • How do I fake an specific browser client when using Java's Net library?
  • How reduce the height of an mschart by breaking up the y-axis
  • How to convert from System.Drawing.Color to Excel.ColorFormat in C#? Change comment color
  • Updating server-side rendering client-side
  • javascript inside java/jsp code
  • Perl system calls when running as another user using sudo
  • Timeout for blocking function call, i.e., how to stop waiting for user input after X seconds?
  • Google cloud sdk not working when python points python3
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Android Studio and gradle
  • Proper folder structure for lots of source files
  • How does Linux kernel interrupt the application?
  • IndexOutOfRangeException on multidimensional array despite using GetLength check
  • How can i traverse a binary tree from right to left in java?