Faraday::ConnectionFailed (Failed to open TCP connection to api.arknode.net:4001 - ruby-on-rails

I am using ark-ruby gem and that code
client = Ark::Client.new(
:ip => 'api.arknode.net',
:port => '4001',
:nethash => '6e84d08bd299ed97c212c886c98a57e36545c8f5d645ca7eeae63a8bd62d8988',
:version => '1.0.1'
)
But it gives an error on heroku that Faraday::ConnectionFailed (Failed to open TCP connection to api.arknode.net:4001 (Connection refused - connect(2) for "api.arknode.net" port 4001)):
How can I fix it?

api.arknode.net has been non-responsive for about a week. HTTPS should be used for that URL. You can try changing that to 5.39.9.240 port 4001 for now and just HTTP.
Note: The network is set up with a list of seed servers. You should use a seed server to get a list of peers in which to make API calls. https://ark.brianfaust.me/#/Peer/peers_getPeers.

Related

Rails cache redis with TLS - Server closed the connection (EOFError)

I am using Digital Ocean managed Redis 7 database but I cannot connect.
The url is:
ENV.fetch("REDIS_CACHE_URL")
rediss://default:password#redis-cache-do-user-id.b.db.ondigitalocean.com:25061/0"
config
config.cache_store = :redis_cache_store, {
driver: :hiredis,
url: ENV.fetch("REDIS_CACHE_URL") { "redis://localhost:6379/1" },
:ssl => true,
ssl_params: { verify_mode: OpenSSL::SSL::VERIFY_NONE },
}
Caching return false
Rails.cache.write('test', 1) => false
Rails.cache.stats
/Users/name/.rvm/gems/ruby-3.1.2/gems/redis-4.7.1/lib/redis/client.rb:306:in `rescue in io': Connection lost (ECONNRESET) (Redis::ConnectionError)
/Users/name/.rvm/gems/ruby-3.1.2/gems/hiredis-0.6.3/lib/hiredis/ext/connection.rb:21:in `rescue in read': Connection reset by peer (Errno::ECONNRESET)
/Users/name/.rvm/gems/ruby-3.1.2/gems/hiredis-0.6.3/lib/hiredis/ext/connection.rb:19:in `read': Server closed the connection (EOFError)
Redis cache exists?
> redis = Redis.new(url: ENV.fetch("REDIS_CACHE_URL"))
=> #<Redis client v4.7.1 for rediss://redis-cache-do-user-id-0.b.db....
> redis.exists?("some_key")
/Users/name/.rvm/gems/ruby-3.1.2/gems/redis-4.7.1/lib/redis/client.rb:306:in `rescue in io': Connection lost (ECONNRESET) (Redis::ConnectionError)
/Users/name/.rvm/gems/ruby-3.1.2/gems/hiredis-0.6.3/lib/hiredis/ext/connection.rb:21:in `rescue in read': Connection reset by peer (Errno::ECONNRESET)
/Users/name/.rvm/gems/ruby-3.1.2/gems/hiredis-0.6.3/lib/hiredis/ext/connection.rb:19:in `read': Server closed the connection (EOFError)
I can correctly connect to redis-cli from the same machine (localhost)
redis-cli --tls -h redis-cache-do-user-id-0.b.db.ondigitalocean.com -a XXXXXXXXXX -p 25061
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
redis-cache-do-user-id-0.b.db.ondigitalocean.com:25061> KEYS *
1) "test"
redis-cache-do-user-id-0.b.db.ondigitalocean.com:25061>
Using other vendor (like RedisLabs) it works. So maybe the issue is something related to connecting from Rails using TLS.
I think the REDIS_CACHE_URL is not correct.
You should confirm the URL is correct
$redis = Redis.new(url: ENV.fetch("REDIS_CACHE_URL"))
$redis.exists?("some_key")

ERROR -- ddtrace: [ddtrace] Failed to open TCP connection to localhost:8126 (Connection refused - connect(2) for "localhost" port 8126)

I am currently working on a ruby on rails project that I have not deployed. While working in a development environment, every time I run rails console or the server I get the full error message:
ERROR -- ddtrace: [ddtrace] (/Users/stevenaguilar/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/ddtrace-0.8.0/lib/ddtrace/transport.rb:73:in `rescue in post') Failed to open TCP connection to localhost:8126 (Connection refused - connect(2) for "localhost" port 8126)
I thought I get around this issue by changing the configuration to work only in production.
config/initializers/datadog-tracer.rb
Rails.configuration.datadog_trace = {
auto_instrument: true,
auto_instrument_redis: true,
default_service: 'my-rails-app'
}
Change the configuration of the file config/initializers/datadog-tracer.rb
this would make it so that ddtrace only works in production.
Rails.configuration.datadog_trace =
{
# may depend by your conditional env
enabled: false,
# these may be 'true' to keep parity with your production
auto_instrument: true,
auto_instrument_redis: true
}

SocketError at /sidekiq/ getaddrinfo: nodename nor servname provided, or not known

I'm a novice Rails dev building an app connected to redis + sidekiq. I must have some configuration error, but I'm not sure what exactly it is. Below, I'll write about what exactly confuses me here:
Upon running rails s, I get the following error:
2016-07-09 08:55:46 - SocketError - getaddrinfo: nodename nor servname provided, or not known:
/Users/rohitrekhi/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/redis-3.3.0/lib/redis/connection/ruby.rb:177:in `getaddrinfo'
/Users/rohitrekhi/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/redis-3.3.0/lib/redis/connection/ruby.rb:177:in `connect'
/Users/rohitrekhi/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/redis-3.3.0/lib/redis/connection/ruby.rb:260:in `connect'
/Users/rohitrekhi/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/redis-3.3.0/lib/redis/client.rb:336:in `establish_connection'
So I figured it must be a redis connection error. When I ping redis to see if connection goes through, it shows the following:
$ redis-cli ping
=> PONG
So if the redis connection goes through, maybe it's a Sidekiq issue?
I implemented the Sidekiq web interface via Sinatra, and got the following error when I tried to view it:
SocketError at /sidekiq/
getaddrinfo: nodename nor servname provided, or not known
So now I'm guessing the error is actually via Sidekiq, but I'm not sure where I dropped the ball via configurations on the host/server/sockets. Any ideas what exactly is causing this and if it's an error with Sidekiq or redis?
This is my initializer file for sidekiq in config/initializers/sidekiq.rb:
Sidekiq.configure_server do |config|
config.redis = { url: 'redis://redis.example.com:6379/12', network_timeout: 5 }
end
Sidekiq.configure_client do |config|
config.redis = { url: 'redis://redis.example.com:6379/12', network_timeout: 5 }
end
And this is my config/initializer/redis.rb:
$redis = Redis.new(:host => 'localhost', :port => 6379)
I've also opened three terminal windows turning on the redis server, sidekiq, and my rails server.
Thanks in advance!
This makes no sense:
redis://redis.example.com:6379/12
You do not have a Redis server at that URL; fix the URL.

Ruby Net::HTTP.start giving connection refused

I have a ruby class in which I am making Net::HTTP.start call inside perform method.This is the code:
class Poller
def self.perform(args)
uri = URI('http://localhost:8081/adhoc/dummy_poll?noAuth=true')
begin
Net::HTTP.start(uri.host, uri.port, :read_timeout=>30) do |http|
request = Net::HTTP::Get.new uri
#response = http.request request
#responsecode = #response.code
end
rescue Exception => e
Rails.logger.error "error mess==>"+e.message()
#responsecode = "408"
end
When I enqueue this within resque from another class using this line:
Resque.enqueue_in_with_queue(:data_workflow_manager,10,Poller,args)
I get this error:
Connection refused - connect(2) for "::1" port 8081.
However, HTTP.start works fine without any errors when the perform method is called in some another class using:
Poller.perform(args)
Please help me understand, why is this happening?
try explicitly connecting to the loop back address. There may be resolution issues with localhost.
uri = URI('http://127.0.0.1:8081/adhoc/dummy_poll?noAuth=true')
It's likely you do not have any server running on port 8081 which is why the connection will be refused.
Check it with lsof -i and look for programs bound to 8081 on a linux machine.

redis local SocketError: getaddrinfo: nodename nor servname provided, or not known

I installed redis in my rails app. everything seems to work fine and I'm running redis server in console. All the ports match. In my initializer:
REDIS = Redis.new(:host => 'localhost', :port => 6379)
in the console:
[3] pry(main)> REDIS
=> #<Redis client v3.0.2 for redis://localhost:6379/0>
but when I try to set something:
[4] pry(main)> REDIS.set("hello", "goodbye")
SocketError: getaddrinfo: nodename nor servname provided, or not known
from /usr/local/rvm/gems/ruby-1.9.3-p0#stacksocial/gems/redis-3.0.2/lib/redis/connection/ruby.rb:112:in `getaddrinfo'
Can someone explain why this is happening?
Finally figured it out. I had edited my hosts file a long time ago so 127.0.0.1 was very custom and wasn't playing nicely with redis. I reverted my hosts file back to the default and it works now.

Resources