7

I'm starting a Wi-Fi Direct access point service using the UWP APIs. It starts OK. I'm using WiFiDirectConnectionListener to monitor for devices that get connected to the access point using the ConnectionRequested event.

var connectionRequest = args.GetConnectionRequest();
var deviceInformation = connectionRequest.DeviceInformation;

// FromIdAsync needs to be called from the UI thread (in MS example).
var isConnected = RunOnUIThreadAsync(() =>
{
    try
    {
        var device = WiFiDirectDevice.FromIdAsync(deviceInformation.Id).AsTask().Result;
        if (device != null)
        {
            device.ConnectionStatusChanged -= OnDeviceConnectionStatusChanged;
            device.ConnectionStatusChanged += OnDeviceConnectionStatusChanged;

            return true;
        }

        return false;
    }
    catch (Exception e)
    {
        // This throws an Exception from HRESULT: 0x800705B4.
        return false;
    }
}).Result; 

On some devices that get connected to the access point, an exception is thrown on calling FromIdAsync with

This operation returned because the timeout period expired. (Exception from HRESULT: 0x800705B4).

In turn, the device that tries to the access point will not connect.

It's always the same devices that are unable to connect, while others connect just fine. I've tried with and without UI thread but the result remains the same. Am I using this wrong, or is this a bug in Wi-Fi Direct? If so, is there another way to start a Wi-Fi Direct access point without the UWP APIs? Perhaps that's working better.

q-l-p
  • 4,304
  • 3
  • 16
  • 36
The Cookies Dog
  • 1,915
  • 2
  • 22
  • 38
  • Have you tried use `await` async key word to replace `AsTask().Result`? – Nico Zhu Apr 08 '19 at 02:17
  • Yes, that didn't help and ended up with the same problem. – The Cookies Dog Apr 08 '19 at 08:16
  • Thanks for the info @NicoZhu-MSFT, would that require an update of Windows or a code change / workaround? It would be nice if there's some way to get this to work reliably. – The Cookies Dog Apr 08 '19 at 08:37
  • @NicoZhu-MSFT I've noticed you've removed your message about the issue report. Any update on this (seeing as you're the only one that responded)? – The Cookies Dog Apr 10 '19 at 11:25
  • I have discussed with related member, Please check if your device support wdf capability. – Nico Zhu Apr 10 '19 at 12:29
  • @NicoZhu-MSFT It is supported and it only happens for *some* devices that try to connect (others work fine). The devices are always the same. I've looked a little into it with Wireshark and there aren't any DHCP offers sent to these faulty devices either (the DHCP discover/requests are received on machine that started the access point). For the working devices I see offers being sent. This makes me think the UWP APIs are relying too much on DHCP. Any update or workaround for this would be appreciated. – The Cookies Dog Apr 10 '19 at 14:39
  • Anything on this @NicoZhu-MSFT? I've been further experimenting with it and if you try to connect a device with a static IP address (I'm only using legacy settings to start the AP) this exception is always thrown. It's useless like this so any workaround would be appreciated. – The Cookies Dog Apr 24 '19 at 06:42
  • 1
    Sorry for my delay, I tested with official code sample , and it also does not connect stably. I will ask product team for help. – Nico Zhu Apr 24 '19 at 06:47
  • Thanks, that sounds good, I'm looking forward to that. – The Cookies Dog Apr 24 '19 at 08:26
  • @NicoZhu-MSFT Have you found anything out? This is a complete breaker for me so any workarounds would be appreciated. – The Cookies Dog May 16 '19 at 09:37
  • @NicoZhu-MSFT Anything on this? Still running into this problem... – The Cookies Dog Jan 08 '20 at 12:54

1 Answers1

0

The workaround to prevent timeout is to have DHCP activated on the client side. I have had this error when trying to connect devices with fixed IP address to the hotspot.

L2M
  • 51
  • 4