Photon doesn't connect on iOS

I have the most rare situation: I am using the PUN plugin for Unity, and I'm building a game with Photon Cloud.

When I call PhotonNetwork.ConnectUsingSettings("1.0"), the game works fine in the UnityEditor. However, it throws this error in Xcode when i try it from the iPad:

[code2=plain]MissingMethodException: Method not found: 'Default constructor not found...ctor() of System.Configuration.ExeConfigurationHost'.
at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00000] in <filename unknown>:0
at System.Activator.CreateInstance (System.Type type) [0x00000] in <filename unknown>:0
at System.Configuration.InternalConfigurationSystem.Init (System.Type typeConfigHost, System.Object[] hostInitParams) [0x00000] in <filename unknown>:0
at System.Configuration.InternalConfigurationFactory.Create (System.Type typeConfigHost, System.Object[] hostInitConfigurationParams) [0x00000] in <filename unknown>:0
at System.Configuration.ConfigurationManager.OpenExeConfigurationInternal (ConfigurationUserLevel userLevel, System.Reflection.Assembly calling_assembly, System.String exePath) [0x00000] in <filename unknown>:0
at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00000] in <filename unknown>:0
Rethrow as ConfigurationErrorsException: Error Initializing the configuration system.
at System.Configuration.ClientConfigurationSystem.get_Configuration () [0x00000] in <filename unknown>:0
at System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection (System.String configKey) [0x00000] in <filename unknown>:0
at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x00000] in <filename unknown>:0
at System.Net.Sockets.Socket.CheckProtocolSupport () [0x00000] in <filename unknown>:0
at System.Net.Sockets.Socket..cctor () [0x00000] in <filename unknown>:0
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for System.Net.Sockets.Socket
at ExitGames.Client.Photon.NConnect..ctor (ExitGames.Client.Photon.EnetPeer npeer, System.String ipPort) [0x00000] in <filename unknown>:0
at ExitGames.Client.Photon.EnetPeer.Connect (System.String ipport, System.String appID, Byte nodeId) [0x00000] in <filename unknown>:0

at ExitGames.Client.Photon.PhotonPeer.Connect (System.String serverAddress, System.String applicationName, Byte node) [0x00000] in <filename unknown>:0
at NetworkingPeer.Connect (System.String serverAddress, System.String appID, Byte nodeId) [0x00000] in <filename unknown>:0
at PhotonNetwork.Connect (System.String serverAddress, Int32 port, System.String appID, System.String gameVersion) [0x00000] in <filename unknown>:0
at PhotonNetwork.ConnectUsingSettings (System.String gameVersion) [0x00000] in <filename unknown>:0
at OnlineManager.Connect () [0x00000] in <filename unknown>:0
at MenuManager.OnRelease (Vector2 pressInfo) [0x00000] in <filename unknown>:0
at Gesture.OnTouchUp (Vector2 pos) [0x00000] in <filename unknown>:0
at BasicDetector.Update () [0x00000] in <filename unknown>:0

(Filename: Line: -1)[/code2]

And when this happens, the code after ConnectUsingSettings is not called. Apart from that, the rest of the game continues to run. But it doesn't connect, and it doesn't call any connection error callbacks.

I must say I get nothing of the code above, since I only operate in Unity and I don't touch the Xcode project at all.
I tracked down the code flow with the debugger, and I saw it gets fine in the NetworkingPeer.cs file, where it dies when executing line 167, which is:

[code2=csharp]// connect might fail, if the DNS name can't be resolved or if no network connection is available
bool connecting = base.Connect(serverAddress, "", nodeId);[/code2]

basically when calling base.Connect.

That's all I know. As I said, the game works fine in the editor. Also, I built another Photon-powered small app WITH THE SAME CODE AND PLUGIN just to check if it was a problem of the iPad (you know, ports, etc.), and it works fine.

Anyone can shed some light on this? Thank you.


  • dreamora
    1. Are you sure you own iOS Pro otherwise it won't work
    2. if you are on untiy 4, ensure to test both the 2.0 subset and the full .net as there are some pretty buggy deltas in the two (especially with stuff missing in full thats in the subset and alike)
  • THANKS! The issue was, I was using .NET 2.0, changing it to .NET 2.0 Subset solved the problem!

    Of course I have Unity iOS Pro, otherwise how could the other demo I made run fine? :D
    Anyway, it's a good question since sometimes newbies made the simplest mistakes.

    Thanks again.
  • dreamora
    I assumed so as well cause otherwise the build would have failed already on the Unity side instead of a runtime error, but its a thing that needs to be cleared.

    Great to hear that it works.
    Should it not be related to stripping, then you best report it as a bug so UT can fix the assemblies it uses for the full for the next release
  • Tobias
    Dreamora: Awesome catch! I'm not sure if I would have found it that fast.
    TinyColossus: I was told by Unity to use "2.0 Subset" and "strip bytecode" for iOS builds and that's what I use now all the time. The error you posted might be due to Unity putting their own constructors into game objects when they compile. This can cause issues. Maybe you submit this as bug to Unity even though you now have working path.
  • dreamora
    If it weren't for the fact that we got hit by this type of error during early U4 betas already, I would potentially not know about it well enough either.

    Our team leader reported the issue back then and I would recommend everyone to report their cases too. This kind of 'big bug' ,that prevents stuff from working in full that works in subset is more than just a tiny thing out of my view and one that needs proper priorization which will only happen if there is enough weight behind the case. (its not the first time, stripping initially was not much better and the subset vs full set in the past had multiple cases like this too which were fixed)