How to build a demo system for syncing using Plugins?

I am building a small syncing system as a demo. It consist of:

1. Rho-Aplication runing on the device - ex. list of product, invetory, etc.

2. Rhoconnect server  runing locally on my PC on port 9292

3. Back-end server runing rails server locally on port 3000.

The syncing should be done using Rhoconnect server and plugins on the rails server side (without source adapter).

I followed the webinar on the same subject.

All three elements separately are working but syncing does not.

Could you please send me the instruction and code for this simple syncing example

thanks

Rafal

Anonymous (not verified)
I have the same environment

I have the same environment and problem.

RhoConnect adapter sends only "/rhoconnect/authenticate" request to Rails app. I have query and other actions fired on RhoConnect side but don't see it's relevant request at Rails app log. I think there should be "/rhoconnect/query" sent by dynamic adapter.

I'm doing everything that need to be done that is specified in documentation.

I figured out that you have to specify :api_token: at settings.yml (which is actually not described in documentation).

I'd also appreciate debugging ideas as I'm kinda stuck with this.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Lars Burgess
:api_token: is only required

:api_token: is only required if you don't start the app up with an environment variable "API_TOKEN". 

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Lars Burgess
Here's the steps I go through

Here's the steps I go through:

  1. Clone the three repos:
  2. Start the rhoconnect app eventtracker-rhoconnect with a specific token:
    • cd eventtracker-rhoconnect
    • bundle install
    • rhoconnect redis-start
    • API_TOKEN=secrettoken rhoconnect start
  3. Start the rails app with the same token:
    • cd eventtracker
    • bundle install
    • RHOCONNECT_URL=http://secrettoken@localhost:9292 rails s
    • Open http://localhost:9292 and check the backend app url, it should be set to "http://localhost:3000".  If not then the token is not correct.
    • Note that you can also put the config.uri in the rhoconnect.rb rails initializer, I just do it this way so the same codebase can be deployed easily elsewhere like heroku.
  4. Start the mobile app:
    • Setup rhodes if you haven't already (comes with RhoMobileSuite)
    • cd eventtracker-client
    • rake run:iphone
    • Login and sync
  5. Try adding a record to the rails app, when you sync again in the iphone simulator you should see the new record.

Vote: 
Vote up!
Vote down!

Points: 1

You voted ‘up’


Anonymous (not verified)
I was trying to follow your

I was trying to follow your steps.

  1. I copied all three repositories from your github into project  folders
  2. and started according to your points
  • cd eventtracker-rhoconnect   - OK
  • bundle install - OK
  • rhoconnect redis-start - Probably NOT-OK.

          In the command line I have:


          C:\Users\BRM738\workspace\eventtracker-rhoconnect>rhoconnect redis_start

          Starting redis in a new window...


          but No new window is popping up and probably redis is not starting.

  • API_TOKEN=secrettoken rhoconnect start - In not working.

          In Command line I have:


          C:\Users\BRM738\workspace\eventtracker-rhoconnect>API_TOKEN=secrettoken rhoconnect start

          'API_TOKEN' is not recognized as an internal or external command,

          operable program or batch file.


     3. Start the rails app with the same token:

    • cd eventtracker - OK
    • bundle install - NOT-OK Eventmachine not installed. CM line:

              Installing eventmachine (0.12.10) with native extensions

              Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

               I am attaching the log file (gem_make.out) for investigation

  • RHOCONNECT_URL=http://secrettoken@localhost:9292 rails s - NOT Working
    • Open http://localhost:9292 and check the backend app url, it should be set to "http://localhost:3000".  If not then the token is not correct. - the filed is empty
    • Note that you can also put the config.uri in the rhoconnect.rb rails initializer, I just do it this way so the same codebase can be deployed easily elsewhere like heroku.

     4. Client Application is working.

===============================================

I tried as well to run the old rake commands instead. Rake was trying to start redis version 2.4.10 from the c:\redis-2.4.10  folder which is not existing. Rhomobilesuite itself is installing redis 2.4.0 (not 2.4.10) in the folder C:/MotorolaRhoMobileSuite2.1.1.7/redis-2.4.0. I found however the config file (redis.rake) located in Rhosuite :


C:\MotorolaRhoMobileSuite2.1.1.7\ruby\lib\ruby\gems\1.9.1\gems\rhoconnect-3.3.6\tasks\redis.rake

and changed there the definition to the existing redis location and existing redis version and then redis started OK.

I think RhoMobileSuite should know where it installs the redis and which version it installs.

Bug? But if Rake will be deprecated soon then maybe it does not make a sense to talk about it.

However the "token" commands still do not work. Neither the whole system.


Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Lars Burgess
Since you're on windows the


Since you're on windows the steps may be different, I'm testing all of this on OSX only.

  C:\Users\BRM738\workspace\eventtracker-rhoconnect>rhoconnect redis_start

          Starting redis in a new window...


          but No new window is popping up and probably redis is not starting.

Ok, using the rake task should be no different so if that works for you that's fine.

              Installing eventmachine (0.12.10) with native extensions

              Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

               I am attaching the log file (gem_make.out) for investigation

Try setting eventmachine in your Gemfile to 1.0.0.  You may have to delete the Gemfile.lock to make it install afterwards.

RHOCONNECT_URL=http://secrettoken@localhost:9292 rails s - NOT Working

Yes this is expected because the rails app isn't starting up due to eventmachine bundle install failure.  If the rails app starts up this should work.

Vote: 
Vote up!
Vote down!

Points: 1

You voted ‘up’


Anonymous (not verified)
Anybody tried this demo on

Anybody tried this demo on Windows?

I tried it on Windows7/64 - not working.

Today I tried it on old Windows XP as well. I could go one step further - The Redis server for Rhoconnect is starting!

However the command to start rhoconnect with API_TOKEN:

API_TOKEN=secrettoken rhoconnect start


is not working.

I could start it however with the normal command:


rhoconnect start


Not working on XP nor on Windows7 is the rails application. I changed the event machine version to 1.0.0. in gemlock and ran the bundle install again. It goes one step further, but it stops on installing libv8 gem:


Installing libv8 (3.3.10.4) with native extensions

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

What to do?

Should I buy a Mac, or does somebody have a running system on Windows as well?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Lars Burgess
API_TOKEN=secrettoken


API_TOKEN=secrettoken rhoconnect start

Since your'e on Windows, the syntax of setting an environment variable is a little different:

$ set API_TOKEN=secrettoken

$ rhoconnect start

The same applies for the rails app:

$ set RHOCONNECT_URL=http://secrettoken@localhost:9292

$ rails s

Please do an update of the eventtracker repo, I pushed up some small changes to make bundle install work on windows.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
I updated the eventtracker

I updated the eventtracker repo.

1. Rhoconnect server is working already. API_TOKEN is set (secrettoken) in the Rhoconnect console!

Before that a Redis server had to be started. On my Win7/64 machine it can only be only with the command:

>Rake redis:start         (the command rhoconnect redis-start - does not work)

2. Rails server is also starting. Before that however I had to run the db migrate command:

>rake db:migrate

But the webpage of the rails server:

localhost:3000

produces failures. Maybe for Windows the rails code has to be modified as well?

==================================================================================================================

LoadError in Events#index

Showing C:/Users/BRM738/RHO/eventtracker/app/views/layouts/application.html.erb where line #14 raised:

cannot load such file -- less (in C:/Users/BRM738/RHO/eventtracker/app/assets/stylesheets/bootstrap_and_overrides.css.less)

Extracted source (around line #14):

11:       <script src="http://html5shim.googlecode.com/svn/trunk/html5.js" type="text/javascript"></script> 12:     <![endif]--> 13: 14:     <%= stylesheet_link_tag "application", :media => "all" %> 15: 16:     <link href="favicon.ico" rel="shortcut icon"> 17:     <link href="images/apple-touch-icon.png" rel="apple-touch-icon"> 

Rails.root: C:/Users/BRM738/RHO/eventtracker

Application Trace | Framework Trace | Full Trace

app/views/layouts/application.html.erb:14:in `_app_views_layouts_application_html_erb__240508308_37783548' app/controllers/events_controller.rb:7:in `index'

Request

Parameters:

None

Show session dump

Show env dump

Response

Headers:

None

============================================================================================

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Lars Burgess
LoadError in Events

LoadError in Events#index

Showing C:/Users/BRM738/RHO/eventtracker/app/views/layouts/application.html.erb where line #14 raised:

cannot load such file -- less (in C:/Users/BRM738/RHO/eventtracker/app/assets/stylesheets/bootstrap_and_overrides.css.less)

I don't think you picked up my latest changes to the app as mentioned earlier.  I removed the less dependency entirely:

https://github.com/larsburgess/eventtracker/commit/d41a28969e9f1ccd45762aab5d5c6b072af13acc

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
I did copy your updated files

I did copy your updated files.

But now when I checked all 3 files and changes you did in gemfile.lock, I saw a few differences. I had some extralines. I deleted my extra lines (these with *.*mingw32) to have it identical then yours and run:

> rails s

again.


I got the same failure and the program recreated in gemfile.lock again the lines which I just deleted.

Where is it defined and configured that when I run the rails server it creates these lines?

All other files seems identical with yours.

What is wrong?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Lars Burgess
Make sure you have the latest

Make sure you have the latest version of both the Gemfile and Gemfile.lock:

https://raw.github.com/larsburgess/eventtracker/master/Gemfile

https://raw.github.com/larsburgess/eventtracker/master/Gemfile.lock

And run `bundle install` to install anything that's missing.  I just verified this on a windows 7 machine with nothing but RhoMobileSuite installed and it works fine.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
All eventtracker repository

All eventtracker repository is exactly the same as yours (after your Windows modifications).

When I start redis, the program is adding some lines to gemfile.lock - probably due to starting rails on Windows.

I tried on both my PCs - Win7/64 and Win XP, re-installed RhoMobileSuite, copied again your repository.

No change. The redis server is always genarating the failure with the cannot load --less file

I force it to work by:

1. deleting phisically the file bootstrap_and_overrides.css.less from ..\eventtracker\app\assets

and

2. deleting the javascript line of code in application.html.erb located in ..eventtracker\app\views\layouts

        <%= javascript_include_tag "application" %>

Whole system started to work together but synching is only in one way. It means when I create something on the device (client), and sync the it is copied to the rails server. The other way is not working.

The connection to rhosync server is ok. I can see the client logged in. Also token is there (secrettoken).

Looks like rhoconnect server does see the rails server but the rails server does not see the rhoconnect server

I start rails with the Rhoconnect URL as you mentioned:

>set RHOCONNECT_URL=http://secrettoken@localhost:9292

>rails s

I am not sure however if it is accepted and where is it stored. How to check it?

Any other hints welcome!

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Lars Burgess
Please try just the latest

Please try just the latest eventtracker code from github, a delete that I made to the .less file didn't make it up there for some reason.  I tried a clean clone of the repo on windows and it is working now.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Anonymous (not verified)
YES!It works just perfectly.

YES!

It works just perfectly. Syncing both ways and no more failures.

Thank you very much Lars.

Looks like it is even possible to separate the users by partitions - like "lars" - default, but I could also add "rafal"  to a separate partition in "event.rb" and their data does not mix in the rails server when they sync. Is it like this?

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Lars Burgess
Yes, the partition method can

Yes, the partition method can return any string you like.  I just return "lars" there as an example.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Alexey Victorov
Lars, thanks! I found that my

Lars, thanks! I found that my problem was - I should have not create empty adapter in RhoConnect app.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Lars Burgess
Great!  Yes you don't want to

Great!  Yes you don't want to have both a source adapter and plugin for the same model, RhoConnect will execute the adapter always if it exists.

Vote: 
Vote up!
Vote down!

Points: 0

You voted ‘up’


Log in to post comments