Forum General Networking issues on Mac

Any issues or discussions relating to Unity development are welcome here.

Networking issues on Mac

Postby runt_struct » November 2nd, 2012, 10:12 am

Has anyone experienced strange networking errors that only occur on Mac and not PC?

Often when I'm trying to make Player.IO calls, I get errors such as this:
Code: Select all
PlayerIOClient.PlayerIOError: GeneralError; Resolving host timed out: api.playerio.com
(strange because the timeout happens instantly)

Code: Select all
PlayerIOClient.PlayerIOError: GeneralError; Recv failure: Connection reset by peer
(takes 2 minutes to error)

Here are some observations I've made:
  • The errors happen frequently, but not consistently. If I execute 50 Player.IO API calls, I might get anywhere from 0 to 30+ errors, averaging ~10.
  • The errors only occur on Mac whereas a PC (running on the same network) executes flawlessly.
  • These errors only occur when I'm making multiple SIMULTANEOUS Player.IO calls - running the same calls back-to-back results in normal operation.
  • I've tried to eliminate as many factors as possible: Multiple Macs on multiple networks yield the same results. I even tried a different API - I got similar results using the Powered by GameSpy SDK. The only common factor I can see is Unity itself.
  • I noticed some Unity forum posts citing similar issues with Unity's WWW class. Does the Player.IO API utilize that class in any way?

Mostly I am just curious if anyone has run into issues like this. I know this post probably belongs on a Unity-specific forum, but given that the only networking I do is through the PlayerIO SDK I'm afraid people will brush off the issue as a specific to the API. I'm quite certain this is NOT a PlayerIO issue. But if anyone has any troubleshooting steps or workaround suggestions it would be much appreciated!
runt_struct
 
Posts: 13
Joined: October 12th, 2012, 7:36 pm

Re: Networking issues on Mac

Postby Benjaminsen » November 2nd, 2012, 11:13 am

Yes we use the WWW API from Unity to power the HTTP based web-service requests to Player.IO.

If indeed this is an issue with the internals of Unity, you could solve it by simply moving the logic to the server and let it interact with Player.IO rather than the client.

This also have the added benefit of increasing security dramatically.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Networking issues on Mac

Postby runt_struct » November 2nd, 2012, 11:46 am

Thanks for the reply, Benjaminsen. You guys are always so prompt with your support. It's awesome! :D
Unfortunately in this case the data really needs to be transmitted to the client for offline use, so a server-side solution isn't possible.

My gut instinct is screaming that this is an issue with Unity internals. Unfortunately I'm not much of a web-oriented person, but I'm going to try my best to find a way to demonstrate that without utilizing PlayerIO. Any suggestions you might have for doing so are most appreciated, and hopefully the guys at Unity will take notice and fix the issue.

In the meantime, I've done my best to work around the problem. The first of the two errors has proven to be not much of an issue because the error comes back instantly and I can then resubmit the PlayerIO request and will usually get a positive result on the 2nd try.

The second error has proven more of a challenge. I obviously can't wait 2 minutes for a callback to process. I've resorted to destroying the class which holds the callback (so I can be assured that it never runs) and resubmitting the PlayerIO request. Is this an acceptable workaround? Will this approach cause any negative side effects?

Thanks!!!
runt_struct
 
Posts: 13
Joined: October 12th, 2012, 7:36 pm

Re: Networking issues on Mac

Postby Benjaminsen » November 2nd, 2012, 11:54 am

If indeed this is an issue with the internals of Unity there is sadly not much we can do to fix it.
However, there is very few cases where you would need to execute more than 2-3 Player.IO requests in quick succession. Therefore it might be worth getting an understanding of what you are trying to do, with the aim of helping you reduce the total request volume.

So, please go ahead and talk a bit about what you are creating.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Networking issues on Mac

Postby runt_struct » November 2nd, 2012, 12:35 pm

Sure, no problem!

In our case we have a table in BigDB that stores 1350 unique items that a player can loot, and that number will only grow. We store things like item names, descriptions, buy price, sell price, requirements for crafting, etc. Because our game is economy-oriented, it's important that we be able to change that data as needed and have it pushed to all clients without going through Apple's submission process for iOS game updates. Furthermore, we don't want to prohibit offline play, thus the issue with running a server-side solution.

When the client is connected to the internet, and subsequently Player.IO, I am running an economy sync function that calculates hash/fingerprint values for the data on the client and refreshes it from BigDB if it appears to be out of date. Right now for convenience I've got the data partitioned into 63 groups of 50 items each so that I can retrieve it (by index) in more manageable chunks.

Theoretically, we'd only want to change a value here and there. So in most cases the client would only end up retrieving one chunk (via one LoadRange call). But if for some reason we made extensive changes to our economy, or the client's local copies files were deleted or tampered with, we could be pushing all of that economy data via as many as 63 simultaneous LoadRange calls. Making those requests back-to-back takes significantly longer.

I haven't determined if these networking errors will actually manifest themselves on the standalone iOS build or not, but they are certainly irritating when we build from the Mac and wipe the environment clean of locally stored files. And since it works great on the PC, I know BigDB and the PlayerIO SDK are up to the challenge. My suspicion is that the Unity guys just didn't stress test their Mac-specific http code.
runt_struct
 
Posts: 13
Joined: October 12th, 2012, 7:36 pm

Re: Networking issues on Mac

Postby Benjaminsen » November 2nd, 2012, 12:54 pm

Make two tables.

One with the list of items, one with the hashes.
For hashes you should be able to store them all in the same BigDB object as they can be up to 512 KB in size.

When game start, load the hash BigDB object, compare with cached set.
Then do a single loadKeys call to load objects that have changed.

This will make the refresh steps be two API operations at worst.
Benjaminsen
.IO
 
Posts: 1444
Joined: January 12th, 2010, 11:54 am
Location: Denmark

Re: Networking issues on Mac

Postby runt_struct » November 2nd, 2012, 1:36 pm

This is a good solution, and one I'll definitely consider. Currently the only drawback on my end is that each of these "chunks" currently consists of 50 conceptually related items that stay in their own class and currently make independent calls to PlayerIO as necessary. The reason for that is partly due to legacy, and partly because they follow the same model (and class) as other data collections, such as player statistics, that are recorded to local files and committed to (or refreshed from) PlayerIO independently of one another. That doesn't mean I can't retool my architecture if necessary, though I'd prefer to avoid it.

In any case, I'd still like to reproduce the WWW issue without using Player.IO and submit it to Unity support. Any suggestions you or anyone else might have for this would be most welcome.

Also, if you or Henrik happen to know whether nullifying a class instance that contains the Player.IO callback for an API call in process could be in any way detrimental to the system, I'd love to hear about it. I haven't encountered any errors with this approach yet, but I always prefer a clean solution.

Thanks again! You guys rock.
runt_struct
 
Posts: 13
Joined: October 12th, 2012, 7:36 pm


Return to General