Sign In Register

How can we help you today?

Start a new topic

Duplicate connections to service upon startup on Android

Hello, lately I have been trying to figure out why on the Android device I always receive double messages from GameSparks (TeamMessage etc.) I found out that whenever I run gamesparks on Android, it will, for some unknown reason, connects to your services twice. I am attaching a debug log where you can notice that after booting your GameSparksTestUI scene the device makes 4 connections to your service : 

Two of them a are on "preview" and two of the are on "gsp-aeu000-se08/09" (which I really do not now what is - can you explain?).


When I run the same scene in editor it will make only 2 connections (but sometimes also 4). Can you explain to me what am I doing wrong and how to prevent these multiple connections? I am running your GameSparksTestUI scene


Here is the log for these 4 connections ( I removed secret keys and device ID, they are same for all 4 connections)



GS: Connecting to:wss://preview-k311217vdgNx.ws.gamesparks.net/ws/device/XXX?deviceOS=ANDROID&deviceID=YYYa&SDK=


GS: Connecting to:wss://preview-k311217vdgNx.ws.gamesparks.net/ws/device/XXX?deviceOS=ANDROID&deviceID=YYYa&SDK=


GS: Connecting to:wss://gsp-aeu000-se08.gamesparks.net/ws/device/XXX?deviceOS=ANDROID&deviceID=YYY&SDK=


GS: Connecting to:wss://gsp-aeu000-se09.gamesparks.net/ws/device/XXX?deviceOS=ANDROID&deviceID=YYY&SDK=


Thanks,

Jan






Hi,


Are you sure you're not calling multiple connections? Maybe your code is being called multiple times?


gsp-aeu000-se08/09 is one of our service servers.


Cheers,

Omar

Hi,

I just tried to create brand new Unity project. Imported GameSparks from Unity Asset Store. Then updated SDK from your website to latest one. And ran the "GameSparksTestUI" scene from you project. In Unity Editor I get only 2 connections ( preview and gsp) but on Android deivce it made 4 connections ( 2x preview and 2x gsp). I made 0 changes in code and the project is empty, only your project from Asset Store. Can you repro this?

Hello,
Could you add GS.TraceMessages = true; in your code? Or try to uncomment the line 55 of GameSparksUnity.cs file and send us the log, please.

Thanks,
Giuseppe

I have added the GS.TraceMessages = true  to my code. The line 55 of GameSparksUnity.cs  in my project refers to just some unimportant comment line but I guess you want me to uncomment the GS.TraceMessages = true which is a line 46 of  GameSparksUnity.cs in my project, just to be exact.


Here is the log from Android Device:


GS: Queue: Reading Persistent Queue

GS: _persistantQueue COUNT : 0

GS: Connecting to:wss://preview-XXX.ws.gamesparks.net/ws/device/XXX?deviceOS=ANDROID&deviceID=6fadbbaeb2e141de978f6906d68f9fc5&SDK=

GS: REMOVING CONNECTION

GS: Connecting to:wss://preview-XXX.ws.gamesparks.net/ws/device/XXX?deviceOS=ANDROID&deviceID=6fadbbaeb2e141de978f6906d68f9fc5&SDK=

GS: OPENED

GS: RECV:{"@class": ".AuthenticatedConnectResponse","connectUrl": "wss://gsp-aeu000-se09.gamesparks.net/ws/device/XXX?deviceOS=ANDROID&deviceID=6fadbbaeb2e141de978f6906d68f9fc5&SDK=","requestId": "0"}

GS: Connecting to:wss://gsp-aeu000-se09.gamesparks.net/ws/device/XXX?deviceOS=ANDROID&deviceID=6fadbbaeb2e141de978f6906d68f9fc5&SDK=

GS: OPENED

GS: RECV:{"@class": ".AuthenticatedConnectResponse","connectUrl": "wss://gsp-aeu000-se08.gamesparks.net/ws/device/XXX?deviceOS=ANDROID&deviceID=6fadbbaeb2e141de978f6906d68f9fc5&SDK=","requestId": "0"}

GS: Connecting to:wss://gsp-aeu000-se08.gamesparks.net/ws/device/XXX?deviceOS=ANDROID&deviceID=6fadbbaeb2e141de978f6906d68f9fc5&SDK=

GS: REMOVING CONNECTION

GS: OPENED

GS: RECV:{"@class":".AuthenticatedConnectResponse","nonce":"882a7426-7c4d-4629-b236-792751625652","requestId":"0"}

GS: SEND:{"@class":".AuthenticatedConnectRequest","hmac":"RGduW9NSpKL9SalCiASnrRbVH5x/OQM1RnWuD1u3VJM=","os":"ANDROID","platform":"Android","deviceId":"6fadbbaeb2e141de978f6906d68f9fc5"}

GS: SOCKET-SEND:{"@class":".AuthenticatedConnectRequest","hmac":"RGduW9NSpKL9SalCiASnrRbVH5x/OQM1RnWuD1u3VJM=","os":"ANDROID","platform":"Android","deviceId":"6fadbbaeb2e141de978f6906d68f9fc5"}

GS: RECV:{"@class":".AuthenticatedConnectResponse","requestId":"0","sessionId":"882a7426-7c4d-4629-b236-792751625652"}

GS: Available

GS: OPENED

GS: RECV:{"@class":".AuthenticatedConnectResponse","nonce":"faf93d64-8f34-4888-bcbc-8e14d031b29f","requestId":"0"}

GS: SEND:{"@class":".AuthenticatedConnectRequest","hmac":"z+1Xls/SRwrhXhyInwVH6sRV+LaA0I8TDqgqNQzAql0=","os":"ANDROID","platform":"Android","deviceId":"6fadbbaeb2e141de978f6906d68f9fc5","sessionId":"882a7426-7c4d-4629-b236-792751625652"}

GS: SOCKET-SEND:{"@class":".AuthenticatedConnectRequest","hmac":"z+1Xls/SRwrhXhyInwVH6sRV+LaA0I8TDqgqNQzAql0=","os":"ANDROID","platform":"Android","deviceId":"6fadbbaeb2e141de978f6906d68f9fc5","sessionId":"882a7426-7c4d-4629-b236-792751625652"}

GS: RECV:{"@class":".AuthenticatedConnectResponse","requestId":"0","sessionId":"882a7426-7c4d-4629-b236-792751625652"}

GS: Available
Hi,
We are not able to reproduce this behaviour, do you know particular conditions which you think they concur with the issue (such as bad connection)?

Giuseppe

 

Hi,

That is strange It is doing 100% time on my 2 Android devices. I have also good Wifi connection. I also tried to create brand new Gamesparks project and connect to it but it is the same. Also notice that these double connections are only occurring only upon startup. When the application is already running and I disconnect and reconnect to service it will correctly connect on once. I am using Unity 2017.1.0f3.

Jan

Are you using Wifi or mobile data connection on your devices? How do you export your project to Android and which settings did you set up?

Giuseppe

 

I use Wifi on android devices. I use "Build & Run" with device connected to PC over USB cable. I left the default settings, see the images.

settings.jpg
(135 KB)

Hi Jan,


What android devices and versions of android are you seeing this behavior on ?


Regards,

Liam

1. Device 

Samsung Galaxy Grand prime  (SM-G531F)

Android  5.1.1

2. Device:

Android 4.1.2

Samsung Galaxy S2 (GT-I9100)



Hi, any new on this issue? Were you able to reproduce it?

Guys, this is still happening. Absolutely easy to repro. Create blank new project in Unity, import Gamesparks plugin downloaded from your website and run the "GameSparkTestUI" scene on ANDROID. Thats all. I get double connection requests consistently upon application startup on all my Android devices ( I have 3 now)..... If I hit "Disconnect" and then "Reconnect" buttons in the scene itself, it will correctly connect only once as it should..... This is 100% repro on my side. I cannot figure out how to get rid of this duplicate connections other than let the application connects at start and then reconnect it again to lose these double connections and get only one. This is literally the only issue that prevents me to put my game into alpha testing :((

I tried to digg as deep as I could and this is what I found out:


The original connection is called at Editor and Android from the same, seemingly correct place, some kind of Initialization of your Gamesparks.Core:


at System.Environment.get_StackTrace()

I/Unity   (10730):    at GameSparks.Platforms.DefaultPlatform.GetSocket(System.String url, System.Action`1 messageReceived, System.Action closed, System.Action opened, System.Action`1 error)

I/Unity   (10730):    at GameSparks.Core.GSConnection.EnsureConnected()

I/Unity   (10730):    at GameSparks.Core.GSConnection..ctor(GameSparks.Core.GSInstance gs, IGSPlatform gsPlatform, System.String currentUrl)

I/Unity   (10730):    at GameSparks.Core.GSInstance.Initialise(IGSPlatform platform)

I/Unity   (10730):    at GameSparks.Core.GS.Initialise(IGSPlatform gSPlatform)

I/Unity   (10730):    at GameSparks.Platforms.PlatformBase.Start()



..... but then on Android only(!) something strange happens. The duplicate connections are called probably because your code decides that new connection is required and creates a new one. Not sure what it is as this is in your binary code and I cannot investigate further :(

 at GameSparks.Platforms.DefaultPlatform.GetSocket(System.String url, System.Action`1 messageReceived, System.Action closed, System.Action opened, System.Action`1 error)

I/Unity   (10730):    at GameSparks.Core.GSConnection.EnsureConnected()

I/Unity   (10730):    at GameSparks.Core.GSConnection..ctor(GameSparks.Core.GSInstance gs, IGSPlatform gsPlatform, System.String currentUrl)

I/Unity   (10730):    at GameSparks.Core.GSInstance.NewConnection()

I/Unity   (10730):    at GameSparks.Core.GSInstance.ConnectIfRequired()

I/Unity   (10730):    at GameSparks.Core.GSInstance.ProcessQueues()

I/Unity   (10730):    at GameSparks.Core.GameSparksTimer.TimerCallback(System.Object state, System.Timers.ElapsedEventArgs e)

I/Unity   (10730):    at System.Timers.Timer.Callback(System.Object state)


Any ideas whats going on? Again, this is 100% report, just create blank new project and put your "GameSparksUnity" script into the scene and run on Android, thats all you need to do.

Hi Jan,


Apologies for the delayed response. I'll run this by the SDK team. Is this happening on all android device builds or just on this specific one ? 


Regards,

Liam

Login to post a comment