microsoft / MixedRealityToolkit-Unity

This repository is for the legacy Mixed Reality Toolkit (MRTK) v2. For the latest version of the MRTK please visit https://github.com/MixedRealityToolkit/MixedRealityToolkit-Unity
https://aka.ms/mrtkdocs
MIT License
6.01k stars 2.12k forks source link

DirectPairing crashes or fails to connect #748

Closed JordanMajd closed 7 years ago

JordanMajd commented 7 years ago

I am having trouble using Direct Pairing. Depending on how I configure it, a crash results or the devices fail to connect.

When direct pairing two devices, the device with DirectParing's Pairing Role set to Connector crashes if its SharingStage's Client Role is set to Secondary or Unspecified and the device with a Pairing Role set to Receiver has it's SharingStage Client Role set to Primary.

If ran in Unity Editor an error box pops up, then Unity crashes and closes:

Runtime Error!

Program:

This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.

If ran on Hololens, Visual Studio debug prints:

The program '[3412] NetworkDemo.exe' has exited with code -1073740791 (0xc0000409).

I am using HoloToolkit-Unity-v1.5.7.0.unitypackage and Unity 5.6.2f1.

Player settings have the following capabilities enabled:

- InternetClientServer
- PrivateNetworkClientServer
- SpatialPerception

Receiver device is configured as follows:

# DirectPairing.cs
Pairing Role: Receiver
Remote Address:  <IP of Receiver>
Remote Port: 2603
Local Port: 2603

# SharingStage.cs
Client Role: Primary
Server Address: localhost
Server Port: 20602
Connect On Awake: False
Auto Discover Server: False
Ping Interval Sec: 2
Is Audio Endpoint: True
Show Detailed Logs: True

Connector device is configured the same, except Pairing Role is set to Connector or Unspecified and Client Role is set as Secondary:

# DirectPairing.cs
Pairing Role: Connector
Remote Address:  <IP of Receiver>
Remote Port: 2603
Local Port: 2603

# SharingStage.cs
Client Role: Secondary or Unspecified
Server Address: localhost
Server Port: 20602
Connect On Awake: False
Auto Discover Server: False
Ping Interval Sec: 2
Is Audio Endpoint: True
Show Detailed Logs: True

If both devices' Client Roles are set to Primary then the application does not crash, but still fails to connect. The Receiver device prints the following message:

SharingService [..\..\Source\Common\Private\SyncManagerImpl.cpp (573)]: Two machines with equal authority levels have connected: breaking the connection to avoid sync data corruption

It seems no matter how I configure DirectPairing it either crashes or fails to connect because of authority levels.

EDIT:

After further testing it seems that setting DirectPairing Pairing Role to Receiver and Sharing Stage Client Role to Secondary or Unspecified results in the Receiver client crashing immediately on launch (no need to configure a Connector device).

StephenHodgson commented 7 years ago

This issue probably belongs in the main HoloToolkit

ShadowshotSys commented 7 years ago

I can reproduce this issue without having a direct sharing component added to my scene. I just need the sharing stage with client role set to something other than Primary (Seconday/Unspecified). Happens in 5.6.2p2 on VS2015.3

StephenHodgson commented 7 years ago

Duplicate of https://github.com/Microsoft/MixedRealityToolkit-Unity/issues/506

StephenHodgson commented 7 years ago

Closing duplicate