MicrosoftDocs / mslearn-mr-adt-in-unity

This is a repo that holds the sample code for the Mixed Reality and Azure Digital Twins in Unity Learn Path
Creative Commons Attribution 4.0 International
65 stars 55 forks source link

unity not receive signalr broadcast data #17

Closed sergiosolorzano closed 1 year ago

sergiosolorzano commented 2 years ago

Hi, the digital twins example works fine for me, thank you for making it available, but when I adapt it to an IoT device (mxchip), the Unity signalr client does not receive broadcast messages. I can see the broadcast messages in the azure funcapp logs but Unity doesn't receive them.

Unity client connection and disconnection subscriptions (rService.OnConnected and rService.OnDisconnected) to signalr fire correctly and get correctly connected/disconnected, but this is not the case for rService.OnTelemetryMessage and rService.OnPropertyMessage in Unity's client ADTDataHandlerr.cs.

I note I have triple checked the Target for signalr is indeed the same in Unity's client at receipt of the message (PropertyMessage and TelemetryMessage).

There are no errors and I can't get Microsoft.Extensions.Logging to work in Unity to get signalr client logs.

Can you please give me a hint what I may be missing as I've posted in stackoverflow and trying for the past couple of days with no avail.

Thank you for your help

broadcast functionapp logs sent but not received by unity:

`2022-09-07T13:47:07.878 [Information] Executing 'broadcast' (Reason='EventGrid trigger fired at 2022-09-07T13:47:07.8784905+00:00', Id=xxx)

2022-09-07T13:47:07.879 [Information] broadcast data :{"data": {"ID": "MachinePart1","TimeInterval": null,"Temperature": null,"Humidity": null,"Pressure": null,"MagnetometerX": null,"MagnetometerY": null,"MagnetometerZ": null,"AccelerometerX": null,"AccelerometerY": null,"AccelerometerZ": null,"GyroscopeX": 0,"GyroscopeY": -70,"GyroscopeZ": 0},"dataschema": "dtmi:digitaltwins:Basic:MachinePart;1","contenttype": "application/json","traceparent": "xxx"}

2022-09-07T13:47:07.879 [Information] broadcast methodMicrosoft.Azure.WebJobs.Extensions.SignalRService.SignalRAsyncCollector`1[Microsoft.Azure.WebJobs.Extensions.SignalRService.SignalRMessage]

2022-09-07T13:47:07.879 [Information] broadcast log at telemetry type:ID - MachinePart1

2022-09-07T13:47:07.879 [Information] broadcast log at telemetry type:TimeInterval -

2022-09-07T13:47:07.879 [Information] broadcast log at telemetry type:Temperature -

2022-09-07T13:47:07.879 [Information] broadcast log at telemetry type:Humidity -

2022-09-07T13:47:07.879 [Information] broadcast log at telemetry type:Pressure -

2022-09-07T13:47:07.879 [Information] broadcast log at telemetry type:MagnetometerX -

2022-09-07T13:47:07.879 [Information] broadcast log at telemetry type:MagnetometerY -

2022-09-07T13:47:07.879 [Information] broadcast log at telemetry type:MagnetometerZ -

2022-09-07T13:47:07.879 [Information] broadcast log at telemetry type:AccelerometerX -

2022-09-07T13:47:07.879 [Information] broadcast log at telemetry type:AccelerometerY -

2022-09-07T13:47:07.880 [Information] broadcast log at telemetry type:AccelerometerZ -

2022-09-07T13:47:07.880 [Information] broadcast log at telemetry type:GyroscopeX - 0

2022-09-07T13:47:07.880 [Information] broadcast log at telemetry type:GyroscopeY - -70

2022-09-07T13:47:07.880 [Information] broadcast log at telemetry type:GyroscopeZ - 0 `

sergiosolorzano commented 1 year ago

the problem was the incoming data wasn't of the type expected by the function and could not deserialize, setting the data to be received to string made this clear.