5 Replies Latest reply on Sep 17, 2012 5:19 PM by Alexander Babichev

    Login error - getaddrinfo: The requested name is valid, but no data of the requested type was found.

      I have a rhomobile app that is connecting to a rhoconnect app.  It's still largely the tutorial code, with the rhoconnect app having one source defined and is also using rhoplugin for a second source running on my Rails server.  The rhoplugin source came in first and was running with no problems.  I then added the rhoconnect source and ran into authentication issues (Rails server is also the api data source for my rhoconnect source, so this was to be expected).  I went to add in token authentication to my source query (using this tutorial for the rails side: http://jessewolgamott.com/blog/2012/01/19/the-one-with-a-json-api-login-using-devise/ and this for the rhomobile side: http://docs.rhomobile.com/rhoconnect/tutorial#authentication) and now I'm getting the error in the title.  I took out all the newly added code for the rhomobile side (Rails server is never getting hit at this point) and am still getting the error.  I'm scratching my head on how to fix because it gives very little info.

       

      The error comes from the mobile app's login_callback method, so the error is being generated by the rhoconnect app, however I can't find anyway to get puts or debug info to come out of that.

        • Re: Login error - getaddrinfo: The requested name is valid, but no data of the requested type was found.

          This error indicates that Socket can not establish the connection.

          Try to reset both Rhodes and Rhoconnect app.

          If you're running RhoSimulator - delete the rhosimulator subdirectory to clean everything.

          For RhoConnect - do 'rhoconnect flushdb'

           

          Also, check the RhoConnect logs - does the login request comes at all to the server?

           

          Max.

            • Re: Login error - getaddrinfo: The requested name is valid, but no data of the requested type was found.

              I've done the reset as described, cleaned the rhosimulator folder from my client app, and did rhoconnect flushdb.  Still getting the error.

               

              I'm not sure where to find the rhoconnect logs, I don't see a file anywhere, but here is the output from the console window when I attempt to login:

               

              [09:25:10 AM 2012-09-12] Use of the POST /application/clientlogin is deprecated. Use Rhoconnect API v1 instead.

              127.0.0.1 - - [12/Sep/2012 09:25:13] "POST /application/clientlogin HTTP/1.1" 500 87 2.5641

               

              So it does appear that the login request is hitting the rhoconnect server

                • Re: Login error - getaddrinfo: The requested name is valid, but no data of the requested type was found.

                  Apparently, you have issues in tour code. Request "POST /application/clientlogin HTTP/1.1" is sent by rhodes app and rhoconect returns 500 (internal server error).

                  You should start with very basic code and make sure it works for you.

                   

                  In rhoconnect 

                  class Application < Rhoconnect::Base

                    class << self

                      def authenticate(username,password,session)

                        true

                      end

                      # ...

                  end

                   

                  In back-end plugin code

                  Rhoconnect.configure do |config|

                    # ...

                    config.authenticate = lambda { |credentials| true }

                    # ... 

                  end

                   

                  Then tweak above code

                  class Application < Rhoconnect::Base

                    class << self

                      def authenticate(username, password, session)

                        # Rhoconnect.api_token is a value of your :api_token field in settings.yml

                        hash = {:login => username, :password => password, :api_token => Rhoconnect.api_token}.to_json

                        headers = {:content_type => :json, :accept => :json}

                        RestClient.post "#{Rhoconnect.appserver}/rhoconnect/authenticate", hash, headers

                      end

                      # ...

                  end

                   

                  And

                  config.authenticate = lambda { |credentials|

                    # validate user/password:  credentials['login']/credentials['password']

                    # return credentials['login'] if they are valid

                    # otherwise            

                    # Rails.logger.error "Rhoconnect#authenticate: Invalid user credentials: #{credentials['login']}/#{credentials['password']}"

                    # return false

                  }