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

Connetion refused error with Rest api client in new plugin code #5

Open
kadivar opened this issue Sep 23, 2015 · 0 comments
Open

Connetion refused error with Rest api client in new plugin code #5

kadivar opened this issue Sep 23, 2015 · 0 comments

Comments

@kadivar
Copy link

kadivar commented Sep 23, 2015

Hi
I'm coding a plugin with colibri-software's plugin supported engine & inside it i'm using a restful api client for interacting with locomotivecms web service but right at starting , web server (puma) encounter to this error:

! Unable to load application: Errno::ECONNREFUSED: Connection refused - connect(2)
/home/kwair/.rvm/rubies/ruby-1.9.3-p551/lib/ruby/1.9.1/net/http.rb:763:in `initialize': Connection refused - connect(2) (Errno::ECONNREFUSED)

I use httparty & rest-client and both of them have this problem. another thing that i have to mention is there is not any problem in shell and through curl , httparty , rest-client & also Advanced Rest client extention of chrome every thing works fine.
in my plugin at first i include this items:

require 'locomotive_plugins'
require "PLUGIN_NAME/version"
require 'uri'
require 'httparty'
require 'locomotive/mounter'

and then code my client same Didier's code sample at (https://gist.github.com/did/725202d5f4417cbbbc72/revisions) this way:

$api_base_url = "ADDRESS"
$api_key = "MY API CODE"
Locomotive::Mounter::EngineApi.set_token(uri: "http://#{$api_base_url}/locomotive/api", api_key: $api_key)
attributes = {
title: 'Hello world',
content: 'Lorem ipsum'
}
query = { query: { 'content_entry' => attributes } }
response = Locomotive::Mounter::EngineApi.post("/content_types/posts/entries.json", query)
if response.success?
puts "article created"
else
puts "failed to create an article"
end
Another official code sample with get & put also encountered to this error.
I test both localhost on my laptop(linux mint 17) and also domain name on my server(centos6) for $api_base_url.
please advice me to pass this big problem.

Thanks

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

1 participant