Problems testing sample apps(SugarCRM and Lighthouse) using iPhone Simulator

33 views
Skip to first unread message

Makoto

unread,
Jan 18, 2009, 2:01:33 PM1/18/09
to rhomobile
Hi,
I just got to know about rhodes/rhosync project and very excited that
I can code mobile app using Ruby ( I was in the middle of deciding
whether I should learn Objective C for iphone or Java for Android).
Thank you for the project.

Anyway, I am now following tutorials in wikis and got some issues, and
would like to share the problems I had. Hope someone had similar
problems, and (possibly) solutions.

First, I followed
http://rhomobile.com/wiki/index.php?title=Mobilizing_Your_Application_with_Rhomobile#RhoSync_-_the_Web_Service_Sync_Engine
and I successfully mangaged to sync SugarCRM info. I also tested
LightHouse sample using my own lighthouse account and that worked,too.

Then, I tried to build the sample Rhodes app on Iphone environment to
see if I can see the data from iPhoneSimulator(2.2|Debug), but that
did not work. The below are what I tried.


1. Running sample SugarCRM app (http://rhomobile.com/wiki/index.php?
title=Building_Rhodes_on_Supported_Platforms#XCode_Build)

When I built sample project, iphone simulator came up with "Rhodes"
icon. When I clicked "SugarCRM" => "Accounts" => "Electronics", then I
got "Error message: undefined method `object' for #".
Here is the console log.
http://pastie.org/363996

2. Building accountapp
http://rhomobile.com/wiki/index.php?title=Mobilizing_Your_Application_with_Rhomobile#Building_Your_Rhodes_Application

I followed the above instruction to create accountapp. I followed
instruction pretty much line by line, including url specifying (http://
rhosync.rhohub.com) as url . The only thing I added extra was link to
Account#index page from root index page.

When I built the probject and click "accountapp" => "Account", then I
get "Error message: wrong constant name accountappApplication" error.
Here is the console log.
http://pastie.org/364008

3. Trying sample lighthouse app (connecting to http://rhosync.rhohub.com).

I also tried running lighthouse app. When I clicked "Lighthouse" =>
"Projects" => "Sync", nothing happened, but seems there are lots of
activity at background.
Here is the console log.
http://pastie.org/364010

4. Trying lighthouse app (connecting to http://localhost:3000).
Since the console log indicated fetching data from http://rhosyncdev.rhohub.com,
I suspeced that I did not have access to the http://rhosyncdev.rhohub.com
host. Then I created sample app specifying my local environment where
sample rhosync server is running (and syncing to my own lightouse
account) like below

rhogen model project "http://localhost:3000/apps/4/sources/5" 5
name,description,updated_at

When I ran the simulator, I pretty much got the same error message as
#3, trying to connect to http://rhosyncdev.rhohub.com, rather than
http://localhost:3000
http://pastie.org/364016

This is my struggle this weekend. Please let me know if I miss any or
doing anything wrong.

Regards,

Makoto


Lars Burgess

unread,
Jan 19, 2009, 1:23:47 PM1/19/09
to rhom...@googlegroups.com
Hi Makoto,

Sorry to hear you were running into trouble. It looks like you're
missing the login step in your testing, we recently added
authentication to
rhosync which was missing instructions on the tutorial. The tutorial
has been updated to include these steps:
http://rhomobile.com/wiki/index.php?title=Mobilizing_Your_Application_with_Rhomobile#Testing_Your_Rhosync_Adapter

Once you've created your user and setup the application w/ a
subscription, you can login to the rhodes app by clicking on the
"login" link on the first page. This will allow the client to
authenticate with the rhosync server and start sending/receiving
records.

Please see my responses to your specific questions below.

Regards,
Lars

On Jan 18, 2009, at 11:01 AM, Makoto wrote:

>
> Hi,
> I just got to know about rhodes/rhosync project and very excited that
> I can code mobile app using Ruby ( I was in the middle of deciding
> whether I should learn Objective C for iphone or Java for Android).
> Thank you for the project.
>
> Anyway, I am now following tutorials in wikis and got some issues, and
> would like to share the problems I had. Hope someone had similar
> problems, and (possibly) solutions.
>
> First, I followed
> http://rhomobile.com/wiki/index.php?title=Mobilizing_Your_Application_with_Rhomobile#RhoSync_-_the_Web_Service_Sync_Engine
> and I successfully mangaged to sync SugarCRM info. I also tested
> LightHouse sample using my own lighthouse account and that worked,too.
>
> Then, I tried to build the sample Rhodes app on Iphone environment to
> see if I can see the data from iPhoneSimulator(2.2|Debug), but that
> did not work. The below are what I tried.
>
>
> 1. Running sample SugarCRM app (http://rhomobile.com/wiki/index.php?
> title=Building_Rhodes_on_Supported_Platforms#XCode_Build)
>
> When I built sample project, iphone simulator came up with "Rhodes"
> icon. When I clicked "SugarCRM" => "Accounts" => "Electronics", then I
> got "Error message: undefined method `object' for #".
> Here is the console log.
> http://pastie.org/363996
There is a known issue with created records that have not been
sync'ed will cause this
problem, and it looks like the record you are trying to edit
hasn't been sync'ed to the server
yet. What the client does when it creates a record is assigns a
temporary object ID (in your case it is
'271967075150364002277') and tries to push that record to the
server. However, since the client
is not logged in, it keeps failing to send the record. I would
recommend you uninstall the app from
the simulator and try again (this will load an empty database to
the simulator so you can login and get
records again).

>
>
> 2. Building accountapp
> http://rhomobile.com/wiki/index.php?title=Mobilizing_Your_Application_with_Rhomobile#Building_Your_Rhodes_Application
>
> I followed the above instruction to create accountapp. I followed
> instruction pretty much line by line, including url specifying
> (http://
> rhosync.rhohub.com) as url . The only thing I added extra was link to
> Account#index page from root index page.
>
> When I built the probject and click "accountapp" => "Account", then I
> get "Error message: wrong constant name accountappApplication" error.
> Here is the console log.
> http://pastie.org/364008
This is strange, can you post the contents of your accountapp/
application.rb? It should look like this:

require 'rho/rhoapplication'

class AccountappApplication < Rho::RhoApplication
end

>
>
> 3. Trying sample lighthouse app (connecting to http://rhosync.rhohub.com
> ).
>
> I also tried running lighthouse app. When I clicked "Lighthouse" =>
> "Projects" => "Sync", nothing happened, but seems there are lots of
> activity at background.
> Here is the console log.
> http://pastie.org/364010

This is also because it doesn't appear you're logged in, so the
client can't receive
the list of lighthouse projects from rhosync.

>
>
> 4. Trying lighthouse app (connecting to http://localhost:3000).
> Since the console log indicated fetching data from http://rhosyncdev.rhohub.com
> ,
> I suspeced that I did not have access to the http://rhosyncdev.rhohub.com
> host. Then I created sample app specifying my local environment where
> sample rhosync server is running (and syncing to my own lightouse
> account) like below
>
> rhogen model project "http://localhost:3000/apps/4/sources/5" 5
> name,description,updated_at
>
> When I ran the simulator, I pretty much got the same error message as
> #3, trying to connect to http://rhosyncdev.rhohub.com, rather than
> http://localhost:3000
> http://pastie.org/364016

Looks like the same problem as above, note fetch data message is
complaining (which is probably because of authentication error):

Fetching data from http://rhosyncdev.rhohub.com/apps/4/sources/9?format=json&client_id=c010056b-5340-4e26-bf83-0f362420fc44
2009-01-18 18:52:53.618 rhorunner[18339:3f07] An error occured
connecting to the sync source: 0 returned

Makoto

unread,
Jan 23, 2009, 4:49:46 AM1/23/09
to rhomobile
Hi, Lars.

Thank you for your reply.

For #2, it's same as what you showed to me.

require 'rho/rhoapplication'
class AccountappApplication < Rho::RhoApplication
end

Removing app from iphone was difficult for someone who does not have
iphone like me.
Here is the reference url.
http://www.seasonsecurity.com/how-do-i-uninstall-applications-from-my-iphone-76004

Do I also need to truncate data from sqlite3?

Anyway, I am trying the rest of points you mentioned. Are there any
IRC for this project?

Makoto


On Jan 19, 6:23 pm, Lars Burgess <l...@rhomobile.com> wrote:
> Hi Makoto,
>
> Sorry to hear you were running into trouble.  It looks like you're  
> missing the login step in your testing, we recently added  
> authentication to
> rhosync which was missing instructions on the tutorial.  The tutorial  
> has been updated to include these steps:http://rhomobile.com/wiki/index.php?title=Mobilizing_Your_Application...
>
> Once you've created your user and setup the application w/ a  
> subscription, you can login to the rhodes app by clicking on the
> "login" link on the first page.  This will allow the client to  
> authenticate with the rhosync server and start sending/receiving  
> records.
>
> Please see my responses to your specific questions below.
>
> Regards,
> Lars
>
> On Jan 18, 2009, at 11:01 AM, Makoto wrote:
>
>
>
>
>
> > Hi,
> > I just got to know about rhodes/rhosync project and very excited that
> > I can code mobile app using Ruby ( I was in the middle of deciding
> > whether I should learn Objective C for iphone or Java for Android).
> > Thank you for the project.
>
> > Anyway, I am now following tutorials in wikis and got some issues, and
> > would like to share the problems I had. Hope someone had similar
> > problems, and (possibly) solutions.
>
> > First, I followed
> >http://rhomobile.com/wiki/index.php?title=Mobilizing_Your_Application...
> >http://rhomobile.com/wiki/index.php?title=Mobilizing_Your_Application...
>
> > I followed the above instruction to create accountapp. I followed
> > instruction pretty much line by line, including url specifying  
> > (http://
> > rhosync.rhohub.com) as url . The only thing I added extra was link to
> > Account#index page from root index page.
>
> > When I built the probject and click "accountapp" => "Account", then I
> > get "Error message: wrong constant name accountappApplication" error.
> > Here is the console log.
> >http://pastie.org/364008
>
>     This is strange, can you post the contents of your accountapp/
> application.rb?  It should look like this:
>
> require 'rho/rhoapplication'
>
> class AccountappApplication < Rho::RhoApplication
> end
>
>
>
> > 3. Trying sample lighthouse app (connecting tohttp://rhosync.rhohub.com
> > ).
>
> > I also tried running lighthouse app. When I clicked "Lighthouse" =>
> > "Projects" => "Sync", nothing happened, but seems there are lots of
> > activity at background.
> > Here is the console log.
> >http://pastie.org/364010
>
>     This is also because it doesn't appear you're logged in, so the  
> client can't receive
>     the list of lighthouse projects from rhosync.
>
>
>
>
>
> > 4. Trying lighthouse app (connecting tohttp://localhost:3000).
> > Since the console log indicated fetching data from  http://rhosyncdev.rhohub.com
> > ,
> > I suspeced that I did not have access to thehttp://rhosyncdev.rhohub.com
> > host. Then I created sample app specifying my local environment where
> > sample rhosync server is running (and syncing to my own lightouse
> > account) like below
>
> > rhogen model project "http://localhost:3000/apps/4/sources/5" 5
> > name,description,updated_at
>
> > When I ran the simulator, I pretty much got the same error message as
> > #3, trying to connect tohttp://rhosyncdev.rhohub.com, rather than
> >http://localhost:3000
> >http://pastie.org/364016
>
>     Looks like the same problem as above, note fetch data message is  
> complaining (which is probably because of authentication error):
>
> Fetching data fromhttp://rhosyncdev.rhohub.com/apps/4/sources/9?format=json&client_id=c...

Lars Burgess

unread,
Jan 23, 2009, 12:12:08 PM1/23/09
to rhom...@googlegroups.com
Hi Makoto,

Truncating your rhosync database is probably a good idea from time to
time as you test stuff (you can just delete from the object_values and
client_maps tables).

Good idea about IRC, I'll setup a channel soon.

Thanks!
Lars

Makoto

unread,
Jan 23, 2009, 6:54:56 PM1/23/09
to rhomobile

Hi, Lars. Thank you again for your reply.

Removing app from iphone now seems pointing to correct url, but I
still getting login errors.

To make debugging simpler, I removed some unrelated projects and put
"localhost" for all remaining projects config.rb classes,
so that I can check from server side error log (rhosync) whether
something is hitting or not.

sqlite> select * from sources;
1|3|http://localhost:3000/apps/1/sources/3|
2|2|http://localhost:3000/apps/1/sources/2|
3|1|http://localhost:3000/apps/1/sources/1|
4|5|http://localhost:3000/apps/4/sources/5|

When I try to login, then I keep getting "login invalid" response, but
I don't see any requests at server side error log.

Here is the iphone simulator console output.
http://gist.github.com/51265

Is there any good way to put debugging information at source code, so
that I can find out exactly which url it's hitting at login?

Thanks.

Makoto







On Jan 23, 5:12 pm, Lars Burgess <l...@rhomobile.com> wrote:
> Hi Makoto,
>
> Truncating your rhosync database is probably a good idea from time to  
> time as you test stuff (you can just delete from the object_values and  
> client_maps tables).
>
> Good idea about IRC, I'll setup a channel soon.
>
> Thanks!
> Lars
>
> On Jan 23, 2009, at 1:49 AM, Makoto wrote:
>
>
>
> > Hi, Lars.
>
> > Thank you for your reply.
>
> > For #2, it's same as what you showed to me.
>
> > require 'rho/rhoapplication'
> > class AccountappApplication < Rho::RhoApplication
> > end
>
> > Removing app from iphone was difficult for someone who does not have
> > iphone like me.
> > Here is the reference url.
> >http://www.seasonsecurity.com/how-do-i-uninstall-applications-from-my...

Lars Burgess

unread,
Jan 23, 2009, 8:46:06 PM1/23/09
to rhom...@googlegroups.com
Hi Makoto,

Sorry to hear you're still running into trouble, it appears that your
client is still not logging into the server because it thinks it has a
valid session:

Creating Req Hash
inside RHO.serve...
Params: {"login"=>"admin", "password"=>"admin12"}
Found existing session for url...
Found existing session for url...
Found existing session for url...
Found existing session for url...
Intialized new client_id from source...
RESPONSE:
HTTP/1.1 200 OK
Date: Fri, 23 Jan 2009 23:18:42 GMT
Content-Type: text/html
Content-Length: 724
Connection: close

You'll see in this log trace that it didn't connect to your localhost
because it found an existing session. Can you try uninstalling from
the simulator, launch rhodes, go directly to the login link and try
logging in? If you still see the "found existing session" message
then you might need to do a clean all in xcode, uninstall from
simulator, and do build and go again.

Cheers,
Lars

Makoto

unread,
Jan 24, 2009, 8:07:54 AM1/24/09
to rhomobile
Hi, Lars.

I followed all your suggestions, but again got same problem.

I even tried again by removing "if (!logged_in())" logic at line 101
of SyncManager.m to force logging in, but got the following error
message.

Calling ruby framework
Creating Req Hash
inside RHO.serve...1
"res: {\"status\"=>200, \"message\"=>\"OK\", \"headers\"=>{\"Date\"=>
\"Sat, 24 Jan 2009 12:52:20 GMT\", \"Content-Type\"=>\"text/html\",
\"Content-Length\"=>0, \"Connection\"=>\"close\"}, \"request-body\"=>
\"\"}"
"req: {\"application\"=>\"Settings\", \"model\"=>\"User\", \"action\"=>
\"do_login\", \"request-method\"=>\"POST\", \"request-uri\"=>\"/
Settings/User/do_login\", \"request-query\"=>\"\", \"headers\"=>
{\"Content-Length\"=>28, \"Content-Type\"=>\"application/x-www-form-
urlencoded\", \"Connection\"=>\"keep-alive\", \"User-Agent\"=>
\"Mozilla/5.0 (iPhone Simulator; U; CPU iPhone OS 2_0 like Mac OS X;
en-us) AppleWebKit/525.18.1 (KHTML, like Gecko)\", \"Referer\"=>
\"http://localhost:8080/Settings/User/login\", \"Cookie\"=>
\"rhosync_session=BAh7BiIKZmxhc2hJQzonQWN0aW9uQ29udHJvbGxlcjo6Rmxhc2g6OkZsYXNoSGFzaHsABjoKQHVzZWR7AA
%3D%3D--3aa8bbaf709a97bf0514cfa6f902bdddd6d8cff9\", \"Accept\"=>\"text/
xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/
plain;q=0.8,image/png,*/*;q=0.5\", \"Accept-Encoding\"=>\"gzip, deflate
\", \"Accept-Language\"=>\"en-us\", \"Host\"=>\"localhost:8080\"},
\"request-body\"=>\"login=admin&password=admin12\"}"
Params: {"login"=>"admin", "password"=>"admin12"}
2009-01-24 12:39:55.951 rhorunner[46604:4003] An error occured
connecting to the sync source: 0 returned
2009-01-24 12:39:56.017 rhorunner[46604:4003] An error occured
connecting to the sync source: 0 returned
2009-01-24 12:39:56.201 rhorunner[46604:4003] An error occured
connecting to the sync source: 0 returned
2009-01-24 12:39:56.263 rhorunner[46604:4003] An error occured
connecting to the sync source: 0 returned
Intialized new client_id from source...

NOTE: "res" and "req" are output message I put at line 100 of rho.rb

Let me know if you have other debugging tips.

Thanks.

Makoto

Makoto

unread,
Jan 24, 2009, 9:08:00 AM1/24/09
to rhomobile
Params: {"login"=>"admin", "password"=>"admin12"}
2009-01-24 12:39:55.951 rhorunner[46604:4003] An error occured
connecting to the sync source: 0 returned
2009-01-24 12:39:56.017 rhorunner[46604:4003] An error occured
connecting to the sync source: 0 returned
2009-01-24 12:39:56.201 rhorunner[46604:4003] An error occured
connecting to the sync source: 0 returned
2009-01-24 12:39:56.263 rhorunner[46604:4003] An error occured
connecting to the sync source: 0 returned
Intialized new client_id from source...

NOTE: "res" and "req" are output message I put at line 100 of rho.rb

Let me know if you have other debugging tips.

Thanks.

Makoto

Makoto

unread,
Jan 25, 2009, 2:29:31 PM1/25/09
to rhomobile
Hi, Lars.

Thank you for your help. To sum up, here are what we did to solve my
problem.

1. Unify source url into one.
When you login from simulator, the Rhodes try to login to all url
specified at config.rb

If you want to point to local server(localhost:3000) instead of
default url ("http://rhosyncdev.rhohub.com), make sure you replace
source url from all config files like below (I tested only SugarCRM,
so I got rid of all other projects, such as Siebel and Basecamp).

makoto-macbook:apps makoto$ grep source */*/config.rb
Rhosugar/Account/config.rb:Rho::RhoConfig::add_source("Account",
{"url"=>"http://localhost:3000/apps/1/sources/1", "source_id"=>1})
Rhosugar/Case/config.rb:Rho::RhoConfig::add_source("Case",
{"url"=>"http://localhost:3000/apps/1/sources/2", "source_id"=>2})
Rhosugar/Employee/config.rb:Rho::RhoConfig::add_source("Employee",
{"url"=>"http://localhost:3000/apps/1/sources/3", "source_id"=>3})
accountapp/Account/config.rb:Rho::RhoConfig::add_source("Account",
{"url"=>"http://localhost:3000/apps/1/sources/1", "source_id"=>1})

2. Doing a clean build in xcode.
sqlite local db holds session information unless you completely wipe
out app from the simulator. Here are the steps to wipe out completely.

2.1 Do "reset content and settings" then from the iphone simulator
menu
2.2 Remove iphone/build/Debug-iphonesimulator director from Rhodes
project directory.
2.3 "Build" => "Clean" on Xcode.
2.4 "Build" => "Build and Go" from xcode.

3. Log out /login from simulator.
For some reason, rhodes thinks I was logged in at iphone simulator. If
first login did not work, cancel the login page, go back to main page,
click "Logout", then login again.

4. Rhosync log file permission.
One thing puzzled me was that I did not see Rhodes hitting my local
Rhosync server at log/development.log
It was because log/developlment.log owner was set to root for some
reason, so Rhosync rails server was not able to write it to log, even
though it was hitting the server. Just chmod the file to your account.

Thank you.

Makoto
> ...
>
> read more »

Makoto

unread,
Jan 25, 2009, 3:04:16 PM1/25/09
to rhomobile
Hi, Lars.
> ...
>
> read more »

Makoto

unread,
Jan 25, 2009, 3:12:04 PM1/25/09
to rhomobile
FYI, sorry for sending duplicate info a few times. Looks like I resent
them every time I refreshed reply pages....
> ...
>
> read more »

Lars Burgess

unread,
Jan 26, 2009, 12:37:18 PM1/26/09
to rhom...@googlegroups.com
Hi Makoto,

I've filed issue #233 for the login problem you were experiencing.
For #4 rhosync logfile permission, I think this is
due to the non-existent development.log file when you run

sudo rake gems:install (this generates a new file as root user)

I've updated the wiki with instructions to create this file first
before running gems:install.

Thanks,
Lars

On Jan 25, 2009, at 12:04 PM, Makoto wrote:

>
> Hi, Lars.
>
Reply all
Reply to author
Forward
0 new messages