ERROR - Exception while reading commands from incoming data

My team and I have been developing a MMO styled game for the past few months and I've been testing just by connecting through my LAN. However, we are a point in development where we thought it would be nice to attempt to connect to the server through the internet. I then changed the IP configuration in Photon Control, changed the IP to connect to from the client, port forwarded etc, however to no avail. Not only is the client timing out, but I'm getting a rather strange error in the client. It reoccurs every second or so until timeout, so maybe it has something to do with retrying the connection. Here is the error:

ERROR - Exception while reading commands from incoming data: System.IndexOutOfRangeException: Array index is out of range.
at ExitGames.Client.Photon.Protocol.Deserialize (System.Int32& value, System.Byte[] source, System.Int32& offset) [0x00000] in <filename unknown>:0
at ExitGames.Client.Photon.EnetPeer.ReceiveIncomingCommands (System.Byte[] inBuff) [0x00000] in <filename unknown>:0
UnityEngine.Debug:Log(Object)
View:LogDebug(String) (at Assets/PhotonEngine/Scripts/Views/View.cs:23)
ViewController:DebugReturn(DebugLevel, String) (at Assets/PhotonEngine/Scripts/Controllers/ViewController.cs:59)
PhotonEngine:DebugReturn(DebugLevel, String) (at Assets/PhotonEngine/PhotonEngine.cs:85)
ExitGames.Client.Photon.<>c__DisplayClass2:<EnqueueDebugReturn>b__0()
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:Service()
WaitingForConnection:OnUpdate() (at Assets/PhotonEngine/Scripts/GameStates/WaitingForConnection.cs:9)
PhotonEngine:Update() (at Assets/PhotonEngine/PhotonEngine.cs:54)

I've been stuck on this error (I hope it's why I can't seem to connect) for the past few days. Any help would be greatly appreciated, thanks!

Comments

  • Please check out this thread for some input about "connections to Photon through the internet", portforwarding etc.:
    viewtopic.php?f=5&t=3950&hilit=+port

    I've moved your post to the Unity forum so that my client developer colleagues can help to sort out the client-side error.
  • Thanks I looked into it. It is possible that it is my ISP that is causing the problem, but that would just fail to send the packets to the server. What could possibly be the cause of the strange error I am getting in the client? Also, could you do me a favor and link me to the new Unity Forum post that you moved the OP to? Thanks
  • The Out Of Range error looks suspicious. It might be your ISP or some hardware (theirs or even yours) might corrupt the data in the datagram.
    Photon has feature to add a checksum per package to detect broken packages and discard them. Please enable that before you connect (you only need to do that client-side) and check what happens.

    In the NetworkingPeer constructor, you can add this:
    this.CrcEnabled = true;
    And you can monitor this value to check how much gets dropped: networkingPeer.PacketLossByCrc
  • I think the likely cause would be the ISP, as when I was attempting to host the server there was no error; just wouldn't connect. Now, another team member is attempting to host the server and this error is occuring; still no connection. Also, I would hate to sound ignorant, but what NetworkingPeer are you referring to? I don't have any class named that in my client solution. Or are you referring to an inheritable class perhabs? Thanks
  • You posted in the "Photon Unity Networking" forum, so I thought you use that from the Asset Store. This has a NetworkingPeer class.
    I guess you are using the Photon Unity SDK from our page then?

    If your players want to connect to your servers from outside of a LAN, you need to make sure that the ISP, router and firewalls are all allowing incoming connections to that IP and Port. And: You have to pick a fitting "Game Server IP Config" (in Photon Control) before you start Photon!
  • Ah sorry, this is my first time on Exit Games' forum. I guess I overlooked the 'plugin' in the section title haha.
    Yes, we are using the SDK.
    We have the firewalls setup correctly, and ports forwarded, testing and working with various checkers. Also, we have selected the autodetect public IP option in Photon Control. As far as all the setup goes, everything should be working fine. I suppose the hoster's ISP could be eating packets that are sent to that port.
    Unfortunately, I don't suppose you have a suggestion for the actual error in the OP?
  • I would need a reproduction project to get the error of the original post. Else it's hard to diagnose.
    If you use a public IP on some ISP, you might also want to check if your IP changed over time. Some ISPs assign new IPs from time to time, I think.
  • Currently the private IP is static, and we've checked several times that our public IP is infact what we have set in the client. As far as the project, would the related networking scripts be enough? I would rather not send the entire project if at all possible.
  • Anything that just re-creates the issue for me. Can be a blank scene with just a few scripts.
  • Hastily threw together a test project containing all the necessary networking scripts:

    http://www.mediafire.com/download/qb9pxdav9zf30qp/SAO+Client+Error+3-11-14.zip

    Here are the steps to reproduce the error:
    1) the IP and port i have the client set to is localhost:5055; might as well go ahead to log in with user: test pass: test but it wont make any difference as you cannot connect to the proxy server, just make sure that error doesn't pop up
    2) change the IP to 186.160.2.9 and watch the magic happen
  • Anyways, my team has recently decided to go ahead and buy a cheap VS for testing purposes. I've spent the better half of the day trying to set this up, and once I moved everything over, our server application will start and the client can successfully establish a connection!
    However, once the Server attempts to load up it's NHibernate session (For MySQL if it wasn't obvious), it hits this exception:

    ---> NHibernate.HibernateException: Could not create the driver from NHibernate.Driver.MySqlDataDriver, NHibernate, Version=3.3.1.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4. ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: Unable to find the requested .Net Framework Data Provider. It may not be installed.

    Here are the things I've tried so far:
    Installing .Net 3.5.1 (Inlcluded within the Server)
    Installing .Net 4.5
    Running as admin
    And bashing my head on my desk haha

    The VS is running Windows Server 2008 r2 SP1

    I would rather spend money on actual testing on the server than getting it working right, so any help is appreciated, thanks.
  • Hey,

    we can not support 3rd party libraries like NHibernate, but a quick google search gives the hint that a reference to MySQL.Data.dll in your project could solve this issue.

    Maybe you could give that a try?
  • I already read that post that you must have stumbled upon. If you read lower down on the OP's post, the type of exception is the same, however the specific error is something totally different. I'm still leaning towards something wrong with .Net not being properly setup like it should on our VS, but I'll keep an open mind.

    Your right about NHibernate being a 3rd party library, I suppose I should post elsewhere for more specific support. Thanks
  • Sorry - I'd love to give better help, but we don't have any first-hand experience with NHibernate, so I can only guess here :-(

    Good luck anyways!