Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chapter 3 : Error Api Routing #7

Closed
byanjati opened this issue Mar 4, 2015 · 25 comments
Closed

chapter 3 : Error Api Routing #7

byanjati opened this issue Mar 4, 2015 · 25 comments

Comments

@byanjati
Copy link

byanjati commented Mar 4, 2015

when i'm trying to access sabisu_rails/explorer, i had this error
Connection refused - connect(2) for "api.marketplaceapi.dev" port 80

i had move the project market_place_api to marketplaceapi folder. But the error is keep coming.

@byanjati byanjati changed the title Error Api Routing chapter 3 : Error Api Routing Mar 4, 2015
@kurenn
Copy link
Owner

kurenn commented Mar 8, 2015

Did you restart the application?, also how is the sabisu configuration?

@ghost
Copy link

ghost commented Oct 7, 2015

How can I solve the problem
I'm using pow,
OS : mac os Capitan
ruby : ruby 2.2.1p85
rails : 4.2.4
pow : 0.5.0

I can confirm the other url as blow:
http://api.marketplaceapi.dev:3000/users/1

I can't only http://api.marketplaceapi.dev:3000/sabisu_rails/explorer in chapter 3.
https://gyazo.com/fb549b2c53c9abbfbec092a954d6c02f

@kurenn
Copy link
Owner

kurenn commented Oct 8, 2015

Are you using a multithread server?, something like puma or unicorn?

@ghost
Copy link

ghost commented Oct 9, 2015

umm.. may be, I did't using multithreaded server on local.
I think Just use webrick embedded.

I use ver WEBrick 1.3.1

I checked the process in my local.

I check two ruby process in my local.
is it able to be problem?

ruby 3807 y_kim 12u IPv6 0x70d9ffafb4192263 0t0 TCP localhost:hbci (LISTEN)
ruby 3807 y_kim 13u IPv4 0x70d9ffafbd4a9b03 0t0 TCP localhost:hbci (LISTEN)

@kurenn
Copy link
Owner

kurenn commented Oct 9, 2015

There are two possible solutions:

You can use puma + foreman + Procfile to run it on a single instance.

Procfile

web: bundle exec puma -t 5:5 -p ${PORT:-3000} -e ${RACK_ENV:-development}

The other option is to run the api with Pow and the same rails app with let's say, rails s and go to the sabisu url

@ghost
Copy link

ghost commented Oct 13, 2015

I did it you said. But I can't.
I don't know what's problem.
Are you need gem list I installed?

https://gyazo.com/ec71f3b8d87f7454fc2ab83db8acb24e

@kurenn
Copy link
Owner

kurenn commented Oct 13, 2015

But are you using Foreman?

@ghost
Copy link

ghost commented Oct 16, 2015

I use foreman as blow

11

but error is occur
222

my gem file like as blow

source 'https://rubygems.org'

gem 'rails', '4.2.4'
gem 'sass-rails', '> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '
> 4.1.0'
gem 'jquery-rails'

gem 'active_model_serializers', github: 'rails-api/active_model_serializers'

gem 'devise'

gem 'sabisu_rails', github: 'IcaliaLabs/sabisu-rails'
gem 'compass-rails', github: 'Compass/compass-rails', branch: 'master'
gem 'furatto', github: 'IcaliaLabs/furatto-rails'
gem 'font-awesome-rails'
gem 'simple_form'

gem 'sdoc', '~> 0.4.0', group: :doc

group :development do
gem 'web-console', '~> 2.0'
gem 'spring'
gem 'sqlite3'
end

group :test do
gem 'byebug'
gem 'rspec-rails'
gem 'factory_girl_rails'
gem 'ffaker'
gem 'shoulda-matchers', '>= 3.0.0', require: false
gem 'spring'

gem 'puma'

gem 'foreman'

REF)
432

@kurenn
Copy link
Owner

kurenn commented Oct 23, 2015

You have to access the foreman server, so:

localhost:5000/sabisu_rails/explore

How does the sabisu initializer look like?

@ghost
Copy link

ghost commented Oct 30, 2015

Thank you. I success to see the page.
https://gyazo.com/a6b1fc142e2d28408c9b2f6530092b60

Really appreciate to you.

@kurenn
Copy link
Owner

kurenn commented Oct 30, 2015

Sweet!

I'm closing the issue then

@tarasmatsyk
Copy link

I have the same issue, probably I do something wrong here.
I tried prax and stopped on foreman. Here is my setup

Procfile

web: bundle exec puma -t 5:5 -p 3000 -e ${RACK_ENV:-development}

Gemfile:

gem 'sabisu_rails', github: "IcaliaLabs/sabisu-rails"
gem 'compass-rails'
gem 'furatto'
gem 'font-awesome-rails'
gem 'simple_form'
gem 'puma'
gem 'devise' # api gem 'active_model_serializers'
gem 'rails', '4.2.4'

sabisu initializer

SabisuRails.setup do |config|
  config.base_api_uri = 'api.marketplaceapi.dev'
  config.api_headers = { "Accept" => "application/vnd.marketplace.v1" }
  config.resources = [:users]
  config.default_resource = :users

The app is started with: foreman start -p 3000

And I still get the error if I go to:

localhost:3000/sabisu_rails/explorer

Before the error is shown I see a popup window where I put user name and password.

Any ideas of what could go wrong here?

screenshot from 2015-11-10 23 08 08

@kurenn
Copy link
Owner

kurenn commented Nov 11, 2015

If you are using prax, you have to include the port on the base_uri for the sabisu initializer such as:

SabisuRails.setup do |config|
  config.base_api_uri = 'api.marketplaceapi.dev:3000'
.
.
.

@tarasmatsyk
Copy link

I thought it would work, however in this case I get the timeout error
screenshot from 2015-11-11 23 19 26

I tried prax and foreman as well. Nothing seems to be working.

@kurenn
Copy link
Owner

kurenn commented Nov 11, 2015

It is really weird, if you are using Foreman, try changing the base_uri to the one Foreman provides, and run the rails server on another console session, and try to access...

@tarasmatsyk
Copy link

@kurenn,
so here is what I did:
Step 1. Console session 1.
screenshot from 2015-11-11 23 25 03

Step 2. Console session 2
screenshot from 2015-11-11 23 25 39

Here is my procfile

web: bundle exec puma -t 5:5 -p 4000 -e ${RACK_ENV:-development}

I tried both ports 4000 and 3000 and on both of them I get the same error
screenshot from 2015-11-11 23 26 50

here is my sabisu config
screenshot from 2015-11-11 23 27 16

I spent the whole last saturday debugging usage of httparty and found that it uses port 80 whatever I do. When I define the port explicitly "http://api.marketplace.dev:3000" - I get the timeout error in httparty.

I would like to stick to one option, whatever you would recommend, either prax or foreman. I just want it to work :)

@kurenn
Copy link
Owner

kurenn commented Nov 11, 2015

Are you using prax?

@tarasmatsyk
Copy link

I do, the application is linked to prax. On the screenshots above I used foreman.
I hope it is a typical misconfiguration issue when something very small is missing and it is hard to spot it.

You can just put me on the right direction or the one you would started to investigate.

@kurenn
Copy link
Owner

kurenn commented Nov 11, 2015

If you stop using prax, you have to configure the base_uri to something like:

config.base_uri = "localhost:4000/api"

And then you can access the explorer through localhost:3000/sabisu_rails/explorer.

If you choose this option, you will have to change your routes a bit, in order to respond to an api namespace instead of a subdomain:

Before:

namespace :api, defaults: { format: :json }, constraints: { subdomain: 'api' }, path: '/'  do
end

After:

namespace :api, defaults: { format: :json }, path: '/api' do
end

@tarasmatsyk
Copy link

Ok, finally it started to make sense for me.
The explorer seems to be working but now I have another issue.

Puma caught this error: Attempt to unlock a mutex which is not locked (ThreadError)

Give me some time and I will tell you whether the issue is still valid.
@kurenn, do you have an idea what was wrong with prax?

@kurenn
Copy link
Owner

kurenn commented Nov 11, 2015

It has to be probably with the port used by it and httparty, I'll check out this last gem to see if I can send a pull request ;)

@tarasmatsyk
Copy link

And this is the best thing I have ever seen in my life
screenshot from 2015-11-11 23 53 51

Now I am happy to stop thinking about django as the bigger out of the box feature provider .
Thank you very much, @kurenn !

If I can help you somehow with the fix, I am happy to give a try.

@kurenn
Copy link
Owner

kurenn commented Nov 11, 2015

@tamatsyk Sure, I'll let you know!

I'm really happy you made it to work!

Enjoy!

@lcastrooliveira
Copy link

Tried to make it work here and I had to give up :(
Too hard to get it working

@premsaha24
Copy link

start prax in the background

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants