Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

UnitySocketIO cant receive/emit packet in iOS

Discussion in 'iOS and tvOS' started by Spacez, May 8, 2014.

  1. Spacez

    Spacez

    Joined:
    Apr 19, 2013
    Posts:
    22
    i'm developing apps using Netease UnitySocketIO and implementing server using NodeJS
    everything works well in UnityEditor and in Android

    but when i build the apps to my iPad Air, i cannot receive/emit any packets from/to my server (btw, the log shows that the socket is connected and the server's log shows that it's connected).


    is there any problems about SocketIO with iOS?

    any solutions would be appreciated
    Thank you so much :)
     
  2. Mantas-Puida

    Mantas-Puida

    Unity Technologies

    Joined:
    Nov 13, 2008
    Posts:
    1,864
    I guess you should start looking for errors in Xcode debugger console.
     
  3. Spacez

    Spacez

    Joined:
    Apr 19, 2013
    Posts:
    22
    it has some warnings about SocketIO saying 'bad access'.
    clicking it will result in showing some assembly code.
     
  4. Spacez

    Spacez

    Joined:
    Apr 19, 2013
    Posts:
    22
    here is the picture of my xcode project when built

    $prob_socketio.jpg
     
  5. Spacez

    Spacez

    Joined:
    Apr 19, 2013
    Posts:
    22
    update: i tried printing the 'raw message' that the socket got (by digging into the api class and insert Debug.log in the method that gets the raw message)
    the raw message can be printed successfully (something like: { "name":"login", "args":{}} )

    but the message is not go into the event i registered.
     
  6. Mantas-Puida

    Mantas-Puida

    Unity Technologies

    Joined:
    Nov 13, 2008
    Posts:
    1,864
    We have dedicated troubleshooting section in iOS manual, which is worth reading before digging deeper: http://docs.unity3d.com/Documentation/Manual/TroubleShooting.html#iPhoneTroubleShooting.

    My short advice would be:
    1) collect all stack traces with lldb command: bt all
    2) unfortunately it seems in your case Xcode is picking short translated function name instead of long one, which makes stack trace analysis bit more complicated
    3) you still can click on different stack frames in left Xcode panel, and scroll to the beginning of disassembled function, you should find there C style name of the function, which could give a clue, which exactly C# function is crashing.

    If you are on iOS Pro, it might be worth to try script debugging feature, which should stop debugger at the place where crash is happening.
     
  7. Spacez

    Spacez

    Joined:
    Apr 19, 2013
    Posts:
    22
    thanks for the reply :)

    i think i found the problem
    Netease uses the class SimpleJson to deserialize and serialize all of its Json formats.
    I try change the SimpleJson to JSON with some modification in original Netease's code, and I can emit/receive events!

    some more questions: I have no idea why SimpleJson can not be used in iOS? I'm planning to use XmlSerializer in the future, is it gonna be a problem too?


    Thank you very much for your help :D
     
  8. Mantas-Puida

    Mantas-Puida

    Unity Technologies

    Joined:
    Nov 13, 2008
    Posts:
    1,864
    Unity is compiling .NET bytecode to ARM ahead of time (not JIT), which causes major troubles when used in combination of generics and reflection. And typically universal deserializers rely on reflection.. Though not sure if that's exactly what is causing troubles in your case, as usually people receive different kind of exceptions in such cases. There are only few JSON and Xml parsers that work well on iOS, so my advice would be try it in smaller project before deploying it to your final project, also its worth looking forums for compatibility issues.
     
  9. Spacez

    Spacez

    Joined:
    Apr 19, 2013
    Posts:
    22
    I see.
    btw, Thanks so much for your help :)