Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

(Bug?) Unity app on Android device cannot receive multicast message

Discussion in 'Multiplayer' started by hey_m8, Jul 16, 2016.

  1. hey_m8

    hey_m8

    Joined:
    Apr 15, 2015
    Posts:
    10
    I'm using Unity's Network Discovery component to broadcast an available match to play. I've got it working perfectly between Windows devices but I'm having issues on an android device.

    I have two android devices that I can test on: Sero 7 (tablet), running on a custom kitkat (4.4.4) image and a Moto G 2014 phone running on stock marshmallow (6.0).

    You might be thinking it's the tablet with the custom image that is having the issues but it's actually my stock phone.

    This is how I've tested it so far:

    • Windows to Windows > Host & Listen - OK
    • Windows/Sero 7 Host, Moto G Listen - NO
    • Moto G Host, Windows/Sero 7 Listen - OK
    My phone can correctly broadcast but cannot receive. I assumed that because android has spotty support for multicast that maybe Motorola didn't implement multicast fully, so I downloaded a 3rd party tool to listen for multicast messages on the network, interestingly enough this tool COULD see the message that Unity was broadcasting. I did notice that it seems like the message Unity was broadcasting covered the entire multicast IP range (I tried out several different IPs and kept picking up the message, so just assuming).

    So it would seem that my phone does implement multicasting, and there seems to be something going wrong on Unity's side. Hoping for any advice.

    I'm on Unity 5.3.0f4
     
  2. hey_m8

    hey_m8

    Joined:
    Apr 15, 2015
    Posts:
    10
    In the end I got rid of Unity's NetworkDiscovery class/component and created my own multicasting system in Java and used the library I created as a Unity Android plugin. I used Unity's interop classes AndroidJavaClass & AndroidJavaObject (which are pretty great) to connect it all together.