Skip to Content
Author's profile photo Former Member

Native Android-MBO Non-DOE based approach through Relay Server

After burning my mid-night oil in investigating how to make my android app to talk through relay server, here are few things what I have noticed and would like to share my experience with the android SUP integration through relay server so that it can help you if you are facing few challenges.

If you have been using SUP for some time, then you must have been wondering what happened to the MBS and RBS option while generating the code in SUP 2.1.2 😕 , which was there in all earlier version,  With 2.1.2 there is now a more unified method however both RBS and MBS still exist as such. In android the application registers initially through MBS however the synchronising with the server is done through the RBS method (port 2480 normally). When generating the code however there is no option to select RBS or MBS. It will already be correctly configured to achieve this. Beyond the initial register with the server though, Android should only be using RBS to talk with the application.

When you first connect and register with the server it will need to connect through port 5001 and then synchronize data through port 2480 or 2481 for secure by default (unless changed). You will as a result need both an RBS and an MBS farm for the relay server however with iOS applications (if those are connecting through the relay server) will already use an MBS farm to connect.

As to why it uses both. By nature RBS tends to favor applications which can be used both online and offline. MBS requires more connectivity but sends smaller packages to the device however RBS sends fewer packages to the device but these are larger. Registration to begin with is just a series of messages to verify the device however the main application is designed to also be run-able in “offline mode” using an offline login method which is typical of RBS.

iPhone has the APNS which makes that MBS only really. Blackberry has been RBS since very early versions so changing that would cause people to have to rework any blackberry programs in later versions however the intention is to move the MBS and RBS methods closer together which is why in the SCC for 2.1.2 it states unified and why if you try to generate code in the 2.1.2 Mobile SDK, there is no option to select a communication type. The idea is to bring everything closer together and  the MBS method is the best way to register originally with the server.

So typically, what exactly you have to do is, at first ensure that your able to synchronize by directly connected through SUP alone. How do you do that ? Let’s go through the following steps

1)      1 ) Before registering the application set the connection properties:

/wp-content/uploads/2012/05/1_98013.png

2)      2) Then go for the registration :

/wp-content/uploads/2012/05/2_98014.png

3)      3)  If your application has been successfully registered, then let’s set the property for Synchronization :

/wp-content/uploads/2012/05/3_98081.png

4)      4) And then you can set the personalization parameters, and then you are good to go with the subscription and synchronization

Now once you are done with all the steps mentioned above and if you are able to synchronize then let’s try achieve it through relay server, If at all if you are using Sybase Hosted Relay Server, you need to create 2 farms, one for MBS and another one for RBS, then configure Outbound   enabler in SCC for both the Farms and ensure that status shows as running, let us assume that you have named your Farm-ID for MBS & RBS as developmentMBS and developmentRBS.

In the above mentioned steps, now your HOST will be your Relay Server, PORT & PORT_SYNC will be 80 and the FarmId in step no.1 has to developmentMBS, and then what I did was I have edited the GeneratedDB.java  under the initialize method, and that is tricky,

/wp-content/uploads/2012/05/4_98082.png

This blog post was written when keeping SUP 2.1.2 in mind,

you are yet confused 😕 ? post a question at SAP for Mobile.

I hope this post will be helpful to you, and that was my first blog in SCN, looking forward to see your encouragement. 😎

Thanks you all

Srinivas Divakarla

Assigned tags

      37 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Good invetigation and helpful result!!! 🙂

      Author's profile photo Rakshit Doshi
      Rakshit Doshi

      Awesome work man..

      But one query in this...

      In streamParams.setUrl_Suffix("/cli/iarelayserver/developmentRBS");

      This command is for windows based or linux..I think it is for linux

      For windows is it "/ias_relay_server/client/rs_client.dll/developmentRBS" ??

      Kindly confirm

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Yes, you are correct Rakshit you are correct. 🙂

      Author's profile photo Rakshit Doshi
      Rakshit Doshi

      Hi Srinivas,

      I followed all the steps as guided by you. I am using a sybase hosted relay server. So i set the properties as in the declaration

      then set up the Application properties

      Then as guided by u set the connection properties

      once doing this I set up the connection profile

      Then in the GeneratedDB.java file made the changes

      (DO WE HAVE TO WRITE ANYTHNG IN THE MARKED LINE ABOVE??)

      Both my Farms are also running fine.

      But i am still facing the error

      "Could not connect to server..Verify Relay Server URL Template"

      Did i go wrong somewhere..Kindly Suggest

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      I don't see you are doing anythin wrong over here, where as I would suggest you to use device instead of an emmulator, and before doing that, probably you have un-install the application and you have delete & re-create the SUP user in SCC as well, I hope that will help you.

      Author's profile photo Midhun VP
      Midhun VP

      Why are providing activation code in your code?

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi Midhun,

      Typically the above code is only to provide the knowledge infact you can very much use a text field to read the same dynamically depending upon your usecase.

      If you more questions concerning android SUP development, I would request you, to post a new question, probably you could mention me in that so that I would try to help you out, at the same time it will be helpful for others to search the answer in SCN.

      Regards,

      Srinivas Divakarla

      Author's profile photo Midhun VP
      Midhun VP

      When am trying to connect register am getting the error Error: 558 Message: 'Could not connect to server. Verify Relay Server URL Template'

      can you tell me a solution please

      Author's profile photo Rakshit Doshi
      Rakshit Doshi

      Can you paste the whole code in a new thread and mark srinivas me and whomever you think in the post as this thing is getting messy over here.. we will surely help you out of it.

      Author's profile photo Midhun VP
      Midhun VP

      I meant not on the hard coding of the activation code. I am asking you whether we need to create the user before register(Is it possible to do with giving a activation code)

      Author's profile photo Rakshit Doshi
      Rakshit Doshi

      U have to create a user in the SCC and then give an activation code and supply the same username and activation code from the device and then it will get registered.

      Author's profile photo Former Member
      Former Member

      Great blog dude, thats some finding. It seems crazy to have to deal with both the ports. But am hearing its all RBS in a few months time; including iOS apps. Hope that brings one way of syncing. Fingers crossed.

      Author's profile photo Former Member
      Former Member

      After following all your code suggestion i am still not able to resolve it.

      Even i am facing with the same error..The device is going online but mobilink communcation error is coming when calling synchronize() first time.

      com.sybase.persistence.SynchronizeException: com.ianywhere.ultralitejni12.implementation.JniException: UltraLiteJ Error[-1305]: MobiLink communication error -- code: 57, parameter: HOST, system code: 0Details:

      StreamErrorCode = 57

      StreamErrorMessage = HOST

      I am stuck in this now. I have done all modifications you have suggested. Host i am providing the relay server URL and port number is 80.

      Author's profile photo Former Member
      Former Member

      Hi Srinivas,

      Excellent Work.... 🙂

      Unfortunately, im facing the same problem that Rakshit Doshi had faced. Is there any solution or idea?

      Regards,

      Senthil.

      Author's profile photo Rakshit Doshi
      Rakshit Doshi

      Hi Senthil,

      I am still looking out for the solutions for the same problem but still not able to. As per the blog first if you try it on your local server using ports 5001 and 2480 it will work..Then in the same application change host to relay server and port to 80 it will work again but if you try a new application starting with host as relay server and port as 80 it doesnt...Are you also facing the same problem?

      Author's profile photo Former Member
      Former Member

      Hi Rakshit,

      Yes. My problem also the same. I have tried with local server using 5001 and 2480 , it works fine. If i try to connect through a relay server then i m getting this issue. It doesnt work at first time also... 😥 My code is attached on another thread. have a look.

      http://scn.sap.com/thread/3177087

      Please give some suggestion..

      Regards,

      Senthil.

      Author's profile photo Former Member
      Former Member

      Hello Srinivas,

      I have the same problem and i have tried following your steps, Can you pls have a look at the link below and help us out....

      http://scn.sap.com/community/developer-center/mobility-platform/blog/2012/06/06/sup-212-native-andriod-app-unable-to-connect-through-relayserver

      Author's profile photo Former Member
      Former Member

      Hi Srinivas,

      I have to update the fields, i took the Flight Customer- BAPI_FLCUST_GETLIST and

      BAPI_FLCUST_CHANGE.

      am attaching the code .

      public class DetailActivity extends Activity

      {

          private int surrogateKey;

          @Override

          public void onCreate(Bundle savedInstanceState) {

              super.onCreate(savedInstanceState);

              setContentView(R.layout.detail);

             

              Intent intent = this.getIntent();

              surrogateKey = Integer.valueOf(intent.getExtras().getString("sk"));

              GetList get = GetList.find(surrogateKey);

             

             

             

              final EditText city = (EditText)findViewById(R.id.fname);

              city.setText(get.getCITY());

              final EditText cname = (EditText)findViewById(R.id.lname);

              cname.setText(get.getCUSTNAME());

              final EditText address = (EditText)findViewById(R.id.address);

              address.setText(get.getCUSTOMERID());

              final EditText xcity = (EditText)findViewById(R.id.Xcity);

              final EditText xname = (EditText)findViewById(R.id.Xname);

             

              Button submit = (Button)findViewById(R.id.submit);

              submit.setOnClickListener(new OnClickListener(){

                  @Override

                  public void onClick(View v)

                  {

                      GetList get = GetList.find(DetailActivity.this.surrogateKey);

                      get.setCUSTOMERID(address.getText().toString());

                      Log.i("csutnooo", address.getText().toString());

                      

                     

                      BAPI_FLCUST_CHANGE_CUSTOMER_DATA  bapi = new BAPI_FLCUST_CHANGE_CUSTOMER_DATA();

      //               

                     bapi.setCITY(city.getText().toString());                               

                    

                    

                     Log.i("city", city.getText().toString());

                    

                    

                     bapi.setCUSTNAME(cname.getText().toString());

                    

                     Log.i("customer", cname.getText().toString());

                    

            

                   

                BAPI_FLCUST_CHANGE_CUSTOMER_DATA_X  bapis = new BAPI_FLCUST_CHANGE_CUSTOMER_DATA_X();

                    

                        bapis.setCITY(xcity.getText().toString());

                         

                        Log.i("xcityyy", xcity.getText().toString());

                        

                        bapis.setCUSTNAME(xname.getText().toString());

                        

                        Log.i("xxcustname", xname.getText().toString());

                       

                     

                    get.getUpdateCUSTOMER_DATA_X();

                    get.getUpdateCUSTOMER_DATA();

                     get.getUpdateCUSTOMERNUMBER();

      //               

                   //   get.update();

                      get.submitPending();

                     

                   //  FlightsDB.synchronize();

                     

                     

                      GenericList<SynchronizationGroup> syncGroups = new GenericList<SynchronizationGroup>();

                      syncGroups.add(FlightsDB.getSynchronizationGroup("default"));

                      FlightsDB.beginSynchronize(syncGroups, "");

                      DetailActivity.this.setResult(Activity.RESULT_OK);

                      DetailActivity.this.finish();

                  }});

          }

      }

      Author's profile photo Rakshit Doshi
      Rakshit Doshi

      What is the error that you are facing over here? Is it that the  bapi is not updating with the data that you are submitting?

      Author's profile photo Midhun VP
      Midhun VP

      Hi,

      Thanks a lot for your information bro. I have few questions.

      What is Sybase Hosted Relay Server? In my organisation we tested some ios apps

      for those we given the farm id as 0.

      So if I am going to develop android app do i want to consider the concept of 2 farms?


      Author's profile photo Rakshit Doshi
      Rakshit Doshi

      Sybase hosted relay server is nothing but a relay server without any setup in ur environment. It is hosted on the sybase site. So you dont have to build a relay server in your landscape but u can use it by creating two farms over there one for MBS and one for RBS.

      Only Android uses two farms MBS for registration and RBS for the sake of synchronizing of data.

      For ios u require only a MBS Farm.

      You can build your own relayserver on sybase. Just go to google and search for sybase hosted relay server. First link will take you over there

      Author's profile photo Midhun VP
      Midhun VP

      If there is no relay server means how i will connect to sup from device?

      Building my own relay server is needed?

      Author's profile photo Sergio Ferrari
      Sergio Ferrari

      great job

      thanks so much

      Author's profile photo Former Member
      Former Member

      Very nice document shrinivas.....really very helpful

      Author's profile photo Former Member
      Former Member

      Very useful stuff, Keep it up srinivas....

      Author's profile photo Former Member
      Former Member

      Can you do this kind of blog for Sup 2.1.3 and iOS? haha

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hi Daniel,

      The same concept is applicable for SUP 2.1.3 with iOS a very small change, the only thing is that, you could yet use MBS for Synchronization, backward compatibility is taken care.

      Regards,

      Srinivas Divakarla

      Author's profile photo Former Member
      Former Member

      Hi Srinivas,

      Can you kindly help me with error that I am facing, I am not using any relay server.

      Kindly have a look at the below thread.

      http://scn.sap.com/thread/3278434

      Author's profile photo Former Member
      Former Member

      Hi Srinivas,

      Great post!! It worked great for SUP 2.1.3 but now that I'm trying to make it work for SUP 2.2 I'm having problems. Do you know if something changed or it should still work this way?

      Thanks in advance!

      Regards,

      Lucía Cianelli

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Hello Lucia,

      Are facing any challenges with SUP 2.2? any specific errors? May be you can post it as a question.

      Regards,

      Srinivas Divakarla

      Author's profile photo Former Member
      Former Member

      Hello Srinivas,

      I managed to make it work before but now I'm having difficulties again. I'm getting an error every time it tries to synchronize. The application registers correctly but when it synchronizes I get the following exception:

      com.sybase.persistence.SynchronizeException: com.ianywhere.ultralitejni12.implementation.JniException: UltraLiteJ Error[-1305]: MobiLink communication error -- code: 63, parameter: , system code: 110Details:

      StreamErrorCode = 63

      StreamErrorMessage = null

      I read it may have something to do with a socket that cannot be opened but I don't know how to search for the communication error. Any ideas?

      Thanks in advance,

      Lucia Cianelli

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thank you Lucia, I am glad that my first ever blog post helped you upto some extent, over the time, the number experts has gone up, I would like you to post your problem as a separate question, for me it seems to be different,

      It's Just monday, would be happy to help you Lucia,

      Cheers,

      Srinivas Divakarla

      Author's profile photo Former Member
      Former Member

      Hi Lucia,
      Gald to hear this one worked successfully in 2.1.3 . Now I'm trying in 2.1.3. Its worked without relay server. But can't connect through relay server. Please have a look on this thread http://scn.sap.com/message/14409539

      Author's profile photo Quynh Doan Manh
      Quynh Doan Manh

      I found that with .net application, we dont need to an initialize profile in generate DB class like this post, just change the server name in this class in InternalSynchronize method 🙂

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thank you Quynh,

      By the way, if you are using .net desktop application you might not need relay server! and also there is another small change for C# you will not be having ultraliteJ instead you will be having ultralite for replication based synchronization.

      Author's profile photo Former Member
      Former Member

      Hi Srinivas,

      Can you please help me with error that I am facing. Plase have a look at the below thread.


      http://scn.sap.com/thread/3432938

      Author's profile photo Former Member
      Former Member

      Hi there Mr,

      This was a very Helpfull blog. I was able to connect to Unwired Server and understand the code here exposed. thanks for your work in favor of the community.

      Laguerta