Trying to connect to AppWarp is very unstable with Mac app built with UNITY

0 votes

Lately I am having many problems when connecting to the AppWrp server from an OSX app built with Unity.

iOS builds work perfectly. Even when I have my Unity build platform set to OSX  and run IN the editor it works perfectly.

I only have problems with the final OSX app that Unity builds.

A call to WarpClient.GetInstance().Connect() sometimes is successful and sometimes not.

Amd even if successful the connection drops quickly.

I am using AppWarpUnity,dll (v1.7.6) in my project AppWarp folder. But I think the version is not a problem as everything works with iOS builds and when testing in the editor

NOTE: Also in my project Appwarp folder is App42_Unity3D_SDK_2.9.3.dll

closed with the note: Closing this thread as there was no update from last 2 Weeks or more. Please raise a new query if problem persists.
asked Oct 18, 2014 in AppWarp by huffman (17 points)
closed Aug 17, 2015 by sushil
Hi Huffman,

Could you please share the logs when you are trying to connect?
Also if you are using connection resiliency or not? if yes, does it connect automatically?
I am not using connection resiliency. And which logs should I give you?
What result codes are you receiving in callbacks?
Could this be the problem:

#if UNITY_WEBPLAYER
        WarpClient.initialize(apiKey,secretKey,"appwarp.shephertz.com");
#else
        WarpClient.initialize(apiKey,secretKey);
#endif
WarpClient.setRecoveryAllowance(60);


Let me do a few more tests. When running in the Editor everything is fine. When it is a built Mac App it is bad…the connection drops. At first I though the connection dropping was causing problems. But now I think the Mac App is hanging which is causing the connection to drop.
When I try creating rooms and getting rooms while running in the Unity editor everything is fine with no errors. But when I try the same thing in a built Mac app I get  "SocketException: Invalid arguments" errors:

================== WarpClient.GetAllRooms ()
Message
=======
SocketException: Invalid arguments

Time
====
15:54:34.940

StackTrace
==========
System.Net.Sockets.Socket.get_RemoteEndPoint ()
com.shephertz.app42.gaming.multiplayer.client.ClientChannel.Send (com.shephertz.app42.gaming.multiplayer.client.message.WarpRequestMessage msg, System.Byte[] data, Int64 length)
com.shephertz.app42.gaming.multiplayer.client.ClientChannel.SendRequest (com.shephertz.app42.gaming.multiplayer.client.message.WarpRequestMessage authMsg)
com.shephertz.app42.gaming.multiplayer.client.WarpClient.GetAllRooms ()

================= WarpClient.CreateRoom()
Message
=======
SocketException: Invalid arguments

Time
====
15:57:06.050

StackTrace
==========
System.Net.Sockets.Socket.get_RemoteEndPoint ()
com.shephertz.app42.gaming.multiplayer.client.ClientChannel.Send (com.shephertz.app42.gaming.multiplayer.client.message.WarpRequestMessage msg, System.Byte[] data, Int64 length)
com.shephertz.app42.gaming.multiplayer.client.ClientChannel.SendRequest (com.shephertz.app42.gaming.multiplayer.client.message.WarpRequestMessage authMsg)
com.shephertz.app42.gaming.multiplayer.client.WarpClient.CreateRoom (System.String name, System.String owner, Int32 maxUsers, System.Collections.Generic.Dictionary`2 tableProperties, Int32 cleanupTime)
===================================
I am now using the latest AppWarpUnity.dll and I still get those "SocketException: Invalid arguments" errors. What could cause such an error to happen when it is a build Mac app, but not when it is the Unity Editor?
I will test it out on Mac and will let you know here on this thread.
Hi,

I tested AppWarp's Unity SDK on Mac, and it seems to work perfectly. Can you share your project with us at support@shephertz.com
Hello Suyash, Thanks for your help.

I worked 14 hours today on this problem but still can't solve it...

The weird thing is it runs perfectly in the editor but not when it is a built Mac app. And it is hard to get any log info from it because there are no errors up to the point of failure then it just hangs and I have to force-quit it.

Anyway, my project is very big and I don't want to trouble you if I can solve it. I'll work on it one more day and if I can't solve it by myself tomorrow. I'll send it to you.
Is there some way outside of my app  (e.g. in the AppWarp HQ console) to see if My app has a connection, if any rooms have been created, and if any users are in the rooms?
Ok. But can you also please try out the following sample and let us know.
https://github.com/SuyashMShepHertz/UnityConnectionResiliencySample

Regarding your second query you can try one instance as Mac App and one instance in Unity Editor, to check out what's happening in the game.
I tried UnityConnectionResiliencySample before in the editor and it worked so I didn't think to build a Mac app with it.

But now I just built a Mac app with it and I get the same unstable behavior. It works perfectly in my Editor but the Mac App version will connect and Join/Subscribe to rooms but will hang if I try to .
connect/disconnect/join/subscribe repeatedly (This doesn't happen in the editor) And I got my firewall turned off. I am on Mavericks and using 4.5.5 Unity.

Also If I try hitting the same button (Join or Subscribe Room) more than once, of course I get status = 4, but I also get SocketException: Invalid arguments. Then after that the Get Start always shows "Disconnecting" but never finishes and every command returns 4. And I have to do a Force Quit 2 or 3 times to kill the app.
I tried the same tests on an old 2005 MacBook running OSX 10.6.8 but with the same Unity 4.5.5. UnityConnectionResiliencySample is perfectly stable in the editor and never gives errors, but a built Mac App is unstable here too. I can successfully connect/Join/Subscribe/Chat but it often crashes instead of hangs. Especially if I try to Subscribe more than once. I put the crash log in dropbox:

https://www.dropbox.com/s/zfquhnp80gndnlq/crash.rtf?dl=0
I think I found the problem...64-bit builds are not supported. When I build and select Architecture x86_64 I have these problems. But if I use x86 then there is no problem.
Yes this could be the reason. I was testing the 32-bit build. I will test it on 64bit also and will let you know. I will investigate more to understand what happens when building for 64-bit systems.
Well I got it running perfectly in a Mac build if I do a simple x86 build instead of a x86_64. Now I got another problem. Testing on iOS with the latest dlls (v1.10 AppWarpUnityMobile) just trying to connect causes a crash. So to make sure it was not my game I copied that AppWarpUnityMobile into the UnityConnectionResiliencySample project and built for iOS.

https://dl.dropboxusercontent.com/u/34724021/UnityConnectionResiliencySample-iOS.zip

When I run it, it crashes. I can see it in xcode in the cleanup routine running in thread 7 "[UnityWWWConnectionDelegate cleanup]":

+ (NSMutableURLRequest*)newRequestForHTTPMethod:(NSString*)method url:(NSURL*)url headers:(NSDictionary*)headers
{
    static Class targetClass = nil;
    if(targetClass == nil)
    {
        targetClass = NSClassFromString([NSString stringWithUTF8String:WWWRequestProviderClassName]);
        NSAssert([targetClass conformsToProtocol:@protocol(UnityWWWRequestProvider)], @"You MUST implement UnityWWWRequestProvider protocol");
    }

    return [targetClass allocRequestForHTTPMethod:method url:url headers:headers];
}

- (void)cleanup
{
    [_url release];
    _url = nil;

    [_responseHeader release]; Thread 7:EXC_BAD_ACCESS (code=1, address=0x18)
    _responseHeader = nil;

    [_connection cancel];
    [_connection release];
    _connection = nil;

    [_data release];
    _data = nil;
}
I found that the problem mentioned in my previous post is due to a problem with Unity 4.5.5 when running on Mavericks. To narrow it down I did some tests:

Mavericks   xcode 6.1   Unity 4.5.5            -crashes
Mavericks   xcode 6.1   Unity 4.5.4p3            -good

Mavericks   xcode 5.1.1  Unity 4.5.5            -crashes
Mavericks   xcode 5.1.1  Unity 4.5.4p3            -good

Mountain Lion  xcode 5.1.1  Unity 4.5.5            -good
Mountain Lion  xcode 5.1.1  Unity 4.5.4p3        -good

As you can see it is the combination of Mavericks and Unity 4.5.5.
It must not be the xcode version because Unity 4.5.5 crashes with both xcode 6.1 & xcode 5.1.1.
Also Unity 4.5.5 doesn’t crash on Mountain Lion. I didn’t test it with xcode 6.1 on Mountain Lion

I also notified Unity about this problem. For the mean time when I build to iOS I will use Unity 4.5.4.
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...