0

Stuck in `bus.joinSession` [solved]

asked 2014-06-23 02:26:17 -0700

yan.foto gravatar image

updated 2014-06-26 02:40:22 -0700

THE PROBLEM HAS BEEN SOLVED - SEE BELLOW

I have two units (one written in C++ and the other in Java) both providing own services. The C++ client can always join a session with the Java client and transmit data, but the Java client gets stuck in bus.joinSession (inside foundAdvertisedName method of BusListener). My C++ provides its service as follows:

  1. Start (bus.Start()) and connect (bus.Connect("unix:abstract=alljoyn")) to the bus
  2. Create a BusProperty (by inheriting from BusObject and implementing Get and Set methods)
  3. Register the BusProperty with the Bus (bus.RegisterBusObject(*this))
  4. Initialize a session by binding the port (bus.BindSessionPort) and passing a SessionPortListener
  5. Advertising the service (bus.AdvertiseName)

The Java client discovers the advertisement and tries to join a session with C++ unit but it gets stuck in bus.joinSession. Any comments on why this might happen?

I really appreciate any kind of clues and comments.

UPDATE

It may be noteworthy to mention that my bus.joinSession is inside a foundAdvertisement callback. So I figured out that by enabling concurrent calls bus.enableConcurrentCallbacks() the problem of stucking is solved but Forgetting jglobalref: ER_ALLJOYN_JOINSESSION_REPLY_UNREACHABLE error is thrown. Leaving the concurrent calls off and using the asynchronous version of joining the bus leads in joining a session with ID 0.

WHAT DID THE TRICK? After applying two changes to the code, I got it up and running:

  1. Request a well-known (bus.RequestName) name in my C++ program
  2. Add a suffix to the service name (to make it unique)

However since only one program was advertising the service, I don't think that step 2 was really crucial to the solution.

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2015-03-02 12:35:03 -0700

ry.jones gravatar image
Linux Foundation Staff

WHAT DID THE TRICK? After applying two changes to the code, I got it up and running: 1.Request a well-known (bus.RequestName) name in my C++ program 2.Add a suffix to the service name (to make it unique)

However since only one program was advertising the service, I don't think that step 2 was really crucial to the solution.

edit flag offensive delete publish link more
0

answered 2014-06-25 17:59:22 -0700

mitchw gravatar image

When developing an Android AllJoyn application, I would recommend to structure your code to make your AllJoyn calls via a separate thread and a Handler (see the Android Basic Client as an example).

This way, when you receive a FoundAdvertisedName, you can take the info from that callback, put it in a msg, and give that to the Handler, which can then perform the Join Session. This also avoids having to use enableConcurrentCallbacks.

edit flag offensive delete publish link more

Comments

Thanks but this is not an Android application. It's a simple Java one! And the procedure is the same as the sample file `alljoyn_core/samples/.../JavaSDKDocPropertiesClient/Client.java". It might be worth mentioning that I don't have any problems creating a session between Android and (simple) Java.

yan.foto ( 2014-06-26 01:02:58 -0700 )edit
Login/Signup to Answer

Question Tools

Follow
1 follower

Stats

Asked: 2014-06-23 02:26:17 -0700

Seen: 348 times

Last updated: Mar 02 '15