RPC works fine in desktop but not in Android

Hi, I got RPCs to work fine when compiling my project to Window/Mac/WebPlayer. However, when I compile my project to Android it doesn't work: it is able to correctly connect to the lobby and to join the room but RPC calls are not triggered.

Need some help.

Thanks for reading.


  • Can you please try to get the console output from the Android device?
    If there's some bug, we need at least to know where it happens.
  • Thanks for your quick reply.

    This is the last part of my output:

    I/Unity (22163): Menu:OnJoinedRoom() (at C:\Users\Jesus\Dropbox\FantasyGame\Assets\Scripts\Menu.cs:64)
    I/Unity (22163): UnityEngine.Component:SendMessage(String, Object, SendMessageOptions)
    I/Unity (22163): NetworkingPeer:SendMonoMessage(PhotonNetworkingMessage, Object[]) (at C:\Users\Jesus\Dropbox\FantasyGame\Assets\Plugins\PhotonNetwork\Network
    I/Unity (22163): NetworkingPeer:OnEvent(EventData) (at C:\Users\Jesus\Dropbox\FantasyGame\Assets\Plugins\PhotonNetwork\NetworkingPeer.cs:1281)
    I/Unity (22163): ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(Byte[])
    I/Unity (22163): ExitGames.Client.P

    More over, I have to say that the last output from this line:


    Is : "PeerCreated" instead of "Joined".
  • Please look out for an exception and save the complete log into a txt file to attach here.
    I'd need more than just the last lines (the problem can have many causes).
  • Plese find attached the complete zipped log file.
    out.zip 39.2K
  • There is no exception or other error logged.
    The only thing that looks suspicious is that there are many (!) SendMonoMessage calls by the NetworkingPeer for just a few DispatchIncomingCommands entries. This means the game maybe has a lot of RPCs which a joining client has to cope with? This could be a problem, if the android version of the game is slower.

    Can you please run the worker demo on your android device and send a few chat messages in it?
    This uses RPCs and works for me.
  • I tried the Angry Bots in my Android device and the RPCs work fine (chat messages). However, I don't know how to fix this problem in my game, as it works well on dekstop. What I do is just:

    1) get list of rooms
    2) join room
    3) send RPC message when connected to the room.

    Only one RPC message is sent when the client connects to a room.

    What am I doing wrong?
  • Do you pause the message queue while loading the level?
    The RPC you send on "loaded" might arrive on the other device while it's loading and get lost (or lose it's target, cause the level is being loaded).
  • I tried pausing the message queue while loading the game scene but it still doesn't work on Android. I tested it in iPad2 and it worked well, but it fails in iPad1. I think that something is broken in the mobile version of your tools or something else must be explained that it's not in the documentation.

    I am not able to send a RPC call correctly at any time of the progam lifetime. I am using only RPC for communication.

    It seems to be an error at the "joining" stage as all the repeated calls you saw in the log happen there and then it seems to break and it can not communicate.

    This is very important to me as I am considering getting a paid license.

    Thanks for answering.
  • Like you said, the Angry Bots demo works and it really is a pretty complex sample already.
    The problem you describe is not a common one and unknown to me, so without knowing more, it's pretty much impossible for me to fix it.

    I can take a look at your project or a repro case, if you provide us with access to it. Either by SVN, AssetServer or Dropbox ZIP of your project.
    Send it to [email protected].
  • I just sent a DropBox invitation to the e-mail you provided with the ZIP file containing our project. Please open the file Board.unity scene from Unity. The file game.cs does all the connection stuff.

    This is how to test the program:
    1- for the master client input a name room in the text field, select the "mydeck" button on the top and press the cube of the middle of the screen.

    2- for the other client, select the button "mydeck" and press the button of the room you created before.

    I tried it on Samsung Galaxy S, Galaxy R and iPad 1 and it failed to communicate with the room. If you do a logcat from an android device you will see that all the weird calls are done in the "joining" stage. At the end, when it joins the room there's no communication at all.

    Thank you so much.

    I really appreciate your time.
  • Are you sure the mail was sent successfully? It doesn't show up in the ticket system yet.
  • I have re-sent the invitation from dropbox (perhaps the older one is in your spam folder) and I just also manually sent a link to the file from my e-mail.
  • You are using "PhotonNetwork.isMessageQueueRunning = true;" but you never pause the queue.

    I tried on Galaxy 3 or something, combined with playmode in Editor. It worked some times for me, some times not.
    That sounds like a timing issue (the description you gave, already pointed in that direction).

    It does take a long time when I create or join a game. I think that's loading the texture which is 170kB. I think that's much. Even more so, when the displayed size is a few pixels. That shouldn't be a problem though.

    In you Menu.OnJoinedRoom(), I first set isMessageQueueRunning to false. At the (very) end, I set it to true again.
    This way, RPCs are queued and not dispatched until loading is done.
    Testing this 3 times (both, as master or not and once to verify), it works nicely.

    Hope this helps.
  • Great! You nailed it! I tried with the PhotonNetwork.isMessageQueueRunning = false but I needed to put it to true at the end of the function as you pointed out and it was only happenning for one of the clients. Now it's working as expected.

    Anyway, I think all the queue stuff is very important to guarantee the robustness of the application and it's not being addressed in the documentation I read online. I would recommend to update it accordingly.

    We finally decided to go for a paid account with photon cloud, not only because of the system itself but also because of the outstanding support you are offering with your users.

    Thank you so much Tobias :)
  • :D
    Thanks a lot for the feedback! When you're happy, we are too.

    I have to admit, I underestimated the importance of the queue pausing.

    I added a short section "Timing for RPCs and Loading Levels". It will need some linking-to, to get everyone up to speed:
    http://doc.exitgames.com/photon-cloud/O ... #_messageQ
Sign In or Register to comment.