question

priyankabhatia-1190 avatar image
priyankabhatia-1190 asked ·

UWP- Peerfinder.ConnectAsync() not able to send request to host machine

Hi,

I am creating UWP application for surface devices and need to transfer data using app when not connected to internet using Wifi-Direct.

I have two surface devices - surface pro 5 and 6. Both have same configuration Windows 10 version 2004.

Below are the issues I am facing while creating connection using Peerfinder between these two devices using Wifi-Direct:
Case 1: Surface 5 (peerfinder is running as Host) and surface 6 (peerfinder is running as Client). Surface 6 (as client) is able to find device surface 5 (host), but when try to connect with surface 5 using Peerfinder.CoonectAsync(peer), surface 6 give error "One or more errors occured while processing the request. (Excep_FromHResult 0x80070306)".

Case 2: Surface 6 (pperfinder is running as Host) and surface 5 (peerfinder is running as Client). Surface 5 is able to send connection request to surface 6, but surface 6 not able process that request. Surface 6 Peerfinder.ConnectAsync(peer) gives error "Arg_ArgumentException".

I also have surface pro 3 device. Surface 3 (Windows 10 version 1909) and surface 5 device are successfully able to create socket using Peerfinder. but they are no able to connect with surface pro 6.

How to resolve this problem with surface pro 6?
Thanks in advance.

Regards






windows-uwpwindows-uwp-runtime
8 comments
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Could you please share some code snippet about the code you are using to connect each other and send or receive data? Another thing is that do you have other devices except these surfaces that could be used to test?

0 Votes 0 · ·

Yes, I have another device which is levono laptop, and also I am nota able to connect any surface device 3,5 and 6 to this because of different wifi manufacturers.
Lenovo has wifi manufactured by intel and surface devices has wifi manufactured by marvell semiconductors.

Code snippet for advertising:
//Start peerfinder as host device
PeerFinder.Role = PeerRole.Host;
PeerFinder.ConnectionRequested += PeerConnectionRequestedForAdvertiser;
PeerFinder.Start();
ConnectionType.Text = "Host Device";

//handle connection requests
private async void PeerConnectionRequestedForAdvertiser(object sender, ConnectionRequestedEventArgs args) {
try{
var _requestingPeer = args.PeerInformation;
await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, async () =>{
try{
var socket = await PeerFinder.ConnectAsync(_requestingPeer);
PeerFinder_StartReader(socket);
} catch (){}
});}catch (){}
}

0 Votes 0 · ·

Code snippet for client:
//Assign Role and start
PeerFinder.Role = PeerRole.Client;
PeerFinder.Start();
ConnectionType.Text = "Client Device";

//Find all hosts
try{
_peerInformationList = await PeerFinder.FindAllPeersAsync();
}catch (){}
try{
if (_peerInformationList.Count > 0){
for (int i = 0; i < _peerInformationList.Count; i++){
ListBoxItem item = new ListBoxItem();
item.Content = _peerInformationList[i].DisplayName;
PeerFinderList.Items.Insert(0, item);
}
}
}catch (){}

//Attach to selected host
peerToConnect = _peerInformationList[PeerFinderList.SelectedIndex];
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, async () =>
{
try{
socket = await PeerFinder.ConnectAsync(peerToConnect);
RecieveData();
}
catch (Exception ex){
error.Text = ex.Message + "\n" + ex.InnerException?.ToString();
}
});

0 Votes 0 · ·

Code snippet for clinet:
//Start peerfinder as host device
PeerFinder.Role = PeerRole.Client;
PeerFinder.Start();
ConnectionType.Text = "Client Device";
_peerInformationList = await PeerFinder.FindAllPeersAsync();
await CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.High, async () =>
{
try{
socket = await PeerFinder.ConnectAsync(_peerInformationList[0]);
RecieveData();
}
catch (Exception ex){
error.Text = ex.Message + "\n" + ex.InnerException?.ToString();
}
});

0 Votes 0 · ·
RoyLi-MSFT avatar image RoyLi-MSFT priyankabhatia-1190 ·

Sure, thank you for sharing the code snippet. Have you got any stack trace or log for both the working scenarios and not working scenarios?

0 Votes 0 · ·

Surface 5 running as host, surface 6 running as client.
Surface 6 identifies surface 5, and tries to connect.

Surface 6 gives error (Message + stack trace):
One or more errors occurred while processing the request. (Excep_FromHResult 0x80070306)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at SharedLibrary!<BaseAddress>+0x4d5c60
at SharedLibrary!<BaseAddress>+0x4d5be8
at SharedLibrary!<BaseAddress>+0x4d5ba7
at SharingAppPOC!<BaseAddress>+0xea6ba

0 Votes 0 · ·
Show more comments

0 Answers