Problem with own southbound interface causing app to stop receving signals

Added by Niklas Mellegård almost 4 years ago

Hi,

I have this problem with an AGA-app. It receives signals just fine until the app is closed and then reopened, after which it stops receiving any signals until the EMULATOR is restarted.

My setup is this:
- A simple AGA-app which listens to vehicle speed, running in the android emulator
- My own implementation of the (south) OEM integration layer, and a simple simulator sending vehicle speed (running in Eclispe on the same machine as the AGA-app)

Issue:
1. Starting the app and the simple simulator, and all runs fine
2. Close the AGA-app in the emulator (e.g. using the home button)
3. Bring back the AGA-app from the task list, or reopen it from the app-drawer in the emulator
4. Now, no more signals are received in the AGA-app until the emulator is restarted

Note in step 4, that recompiling the AGA-app has no effect, the emulator must be closed down and restarted.
Also note, in step 4 the AGA-app can still SEND and REQUEST signals to the simulator (a send-response to the request also reaches the AGA-app just fine).
Final note, I do not have the same issue using the simulator-fx, thus something is probably wrong with my simulator/SDPNode-thingy.

Attached files (the Southbound interface):
- SecureGatewayWrapper.java -- in this file I set up a new SDPNode and gateway.
- SecureGatewaySimulator.java -- This is the simulator, using the wrapper to send simulated vehicle messages to the AGA--side

Suspected issue:
- The shutdown-method in SecureGatewayWrapper.java[174]. This is used from the SGSimulator to close the SDP-connection and let the simulator close down. Note that I can rerun the simulator, all is still fine


All the best,
Niklas

Update: I noticed an error in the shutdown-method (which made no difference to the issue reported), and the update resulted in duplicate attachments. Sorry, but I cant remove them.....

SecureGatewaySimulator.java Magnifier - This is the simple vehicle simulator (2.32 KB)

SecureGatewayWrapper.java Magnifier - The wrapper of SDPNode and SDPPGateway (6.18 KB)


Replies (9)

RE: Problem with own southbound interface causing app to stop receving signals - Added by Christopher Pavlic almost 4 years ago

Hello Niklas and welcome to the AGA forums!

If you like I can delete the duplicate files, if so you can just tell me to remove them and it shall be done.

Regarding your problem, I shall try and help you to the best of my abilities. To increase my chances of success in the matter I would like to ask you a few questions.

  1. Are you using AGA SDK when developing and creating the EMULATOR?

  2. If this is the case which version of our AGA SDK are you using? (1.0 or 1.1)


My initial thoughts after reading about the problem and looking at the code provided:

About the shutdown process in SecureGatewayWrapper-1.java, you should not disconnect the node manually during the shutdown process (line 179), instead do only the "m_oSDPGatewayClient.stop();" (line 180).

I belive that this problem is occurring because of the following events are taking place.

1. Starting the app and the simple simulator, and all runs fine
    node connections are made and signals are provided
2. Close the AGA-app in the emulator (e.g. using the home button)
    app-node connection is broken due to the emulator not using the AGA SDK and thus does not have our proxy service to keep the connection alive meaning that the app-node is most likely killed.
3. Bring back the AGA-app from the task list, or reopen it from the app-drawer in the emulator
    app-node is started again however the new fresh app-node never received the provide from the SecureGateway-node and because of that the app-node will no longer know that the SecureGateway-node is a provider.

Reading about the problem lead me to the assumption that the emulator is not using AGA SDK. And I do believe that this is the reason for the problem. When the SecureGateway-node gets disconnected it tries to re-connect to the same place until it is deleted. When you return the app it will instead reconnect to a new node that never received the initial provide. One solution I can think of is the following: On the gateway-node set a SDPConnectionListener and when a disconnection happens unprovide all signals and when a connection is made provide all signals again. This hopefully should resolve your problems.

Otherwise please contact me again and I shall try to help further.
Best regards
Christopher Pavlic

RE: Problem with own southbound interface causing app to stop receving signals - Added by Niklas Mellegård almost 4 years ago

Hi Christopher,
And thanks for your quick reply!

Yes, please remove the extra attachments. It's the ones with the link numbered 20 and 21 that should be removed.

Regarding your questions:
1) Yes, I'm using the AGA SDK as is
2) Version 1.1, though 1.0 and the snapshot released just after 1.0 both result in the same problem


Regarding your notes:
1) Ok
2) The app is indeed running the AGA SDK, so it should be connected to your proxy
3) This sounds reasonable, but would it account for the fact that SecureGateway still recevies Request events from the app? I.e. it is only messages "northbound" that goes missing when restarting the app, messages from APP to OEM layer still works fine (including the responses to the request)

I made the changes you proposed:
- Added a ConnectionListener to the SDPGateway
- ConnectionListener does the provide-calls on CONNECTED
- ConnectionListener does the unprovide-calls on DISCONNECTED
- shutdown-method no longer disconnects the node

Still, same problem persists (attaching a new version of the SecureGatewayWrapper.java for reference).


Update: It seems the ConnectionListener recieves a CONNECTING and a CONNECTED when the simulation starts, but it does NOT receive a DISCONNECTED when APP is closed. It also never gets the CONNECTING/CONNECTED messages when the APP restarts...

All the best,
Niklas
 

RE: Problem with own southbound interface causing app to stop receving signals - Added by Christopher Pavlic almost 4 years ago

Hello again, sorry to see that the error persists.

As requested I have removed the duplicate attachment you mentioned (20 and 21).

With these results I need to take another look. Unfortunately I do not have enough time to reproduce the scenario right now, but I will take a look at it as soon as I get some time for it. I will reply again to this thread once I start to look into it. We will get to the bottom of this!

Best Regards
Christopher Pavlic

RE: Problem with own southbound interface causing app to stop receving signals - Added by Reza Javaheri almost 4 years ago

Hi Niklas,

I can mention something when I glanced over your code:

Regarding the Connection Status, the reason for not getting "DISCONNECTED" is that the simulator connects to the proxy node running as a system service on Android and even if the app closes down the proxy node still is running in the background and it does not disconnect from your simulator, so it never gets disconnected!

However when you bring your app up again on the Android emulator, you should be able to get those signals again and I can't really see why you are not getting those by looking at the simulator code. Could you attach the code for your app and I hope we should have some clues why it is not getting those signals when it comes back up the second time.


/Reza

RE: Problem with own southbound interface causing app to stop receving signals - Added by Niklas Mellegård almost 4 years ago

Hi Reza,

Attaching the main Android activity class and the class interfacing AGA (I can zip and atatch the whole project if you'd like test it).

I'm afraid this is not the version I originally had the issue with. Though, this version of the app still have the issue, but it now seems to be intermittent; sometimes it does work, and sometimes it doesn't. From some very sparse testing, it seems that the first time I run the simulation after pause/resume or close/restart it doesn't recevie any signals. If I re-run the simulation, it seems to work!

Well, one obvious suspect is that, as subscriptions to the AGA signals are done in an async task (see VechileManager.connect), the app may miss the signals if the simulation is started too soon after the app resumes. But, I assume that running the subscription task cannot take that long, right? Much less than 10 seconds (they're on the same computer)?

Maybe we should write this down to oddities with the emulator or my particular setup, rather than AGA?

EDIT: Reg. CONNECT/DISCONNECT. Ok, that makes sense. Thanks

All the best,
Niklas
 

DashboardActivity.java Magnifier - The Android main activity, managing the app life-cycle (886 Bytes)

VehicleManager.java Magnifier - The class managing the AGA signals (4.98 KB)

RE: Problem with own southbound interface causing app to stop receving signals - Added by Mahan Rad almost 4 years ago

Hello Niklas
This is Mahan, I was just looking at your code and I also created an application based on them and supprisingly every thing seems to work just fine and I should
 mention that I have not made any changes to your code what so ever.
Please allow me to explain what I do to run the system in more details.
Firstly, I have a simulator project in eclipse with the "SecureGatewaySimulator.java" and "SecureGatewayWrapper.java" files.
Secondly, I have an Android application in the Android Studio which contains the "DashboardActivity.java" and "VehicleManager.java" as well as some not-very-important file to satisfy the dependecies.

After setting up these application projects, as instructed in AGA website, I do the port forwarding (only needed the first time after adb is reset; otherwise the simulator starts nagging).
When it comes to running the applications, I run the simulator first and then, right after that, I run the android application (on the emulator).
Once the signals are received and I can see the logs in the emulator's output, then I can re-run the simulator as many times as I want (while keeping the Android applicaiton open in the emulator) and see the signal logs are received again and again.
 
If you want, I can zip and send you the projects so you can compare the codes by yourself.
Please advise me how different is your procedure.

Looking forward
Cheers
/Mahan

RE: Problem with own southbound interface causing app to stop receving signals - Added by Niklas Mellegård over 3 years ago

Hi Mahan,

And thanks for your reply (I've now enabled email notifications, so hopefully it won't take 2 weeks for me to come back :|)...

There is one misunderstanding. I can also re-run the simulator without problem. It is when the Android app is closed and restarted that problems start to happen. I have now also tried it on a Nexus 7 (2013) with the Flo AGA-build (available in early December) running, and it exhibits the same problem (thus ruling out that it is merely oddities with the emulator).

Steps to reproduce:
1. Start the simulator (as you describe above)
2. Run the android app
3. Hit the home button in the emulator (or on the device)
4. Return to the android app (either by flipping through last seen apps, or by tapping the icon again)
5. No more signals are received by the app

Workaround:
In android, go to Settings / Apps and find the android app, Force Stop and Clear Cache. Now, starting the app will again receive signals.

All the best,
Niklas
 

RE: Problem with own southbound interface causing app to stop receving signals - Added by Mahan Rad over 3 years ago

Hello Niklas
I just retested the projects I made based on your code. Using the AGA emulator, I did as following:
 
I just started : 1st-Simulator and 2nd-Application;
   then 1st-I received signals and 2nd-Simulator stopped as expected,

After that I pressed back button and exited the application (into home screen)

Then again I started : 1st-Simulator and 2nd-Application;
   then 1st-I received signals and 2nd-Simulator stopped as expected

BTW, I attached the simulator and android projects for you to consider.
Please take a look at them and let me know in what way might they be different from your projects.

Best
/Mahan

(1-9/9)