With my Ruby script:
imap = Net::IMAP.new('imap.gmail.com')
imap.login("some_email#host.com", password)
I get the following exception:
A connection attempt failed because
the connected party did not properly
respond after a period of time, or
established connection failed because
connected hos has failed to respond. -
connect(2)
What's wrong?
You need to connect using SSL on port 993.
Therefore your code should be this:
imap = Net::IMAP.new('imap.gmail.com', 993, true)
imap.login("user#host.com", "password")
Related
Has anyone faced this issue while connecting to an Oracle DB from Logstash JDBC Input Plugin :
[2021-07-22T11:22:42,912][ERROR][logstash.inputs.jdbc ][main][9615a4202c23f17db8abee168682c63c25349f105e2579d02086d38fe8145d97] Unable to connect to database. Trying again {:error_message=>"Java::JavaSql::SQLRecoverableException: IO Error: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond, Authentication lapse 0 ms."}
[2021-07-22T11:22:42,922][ERROR][logstash.inputs.jdbc ][main][b9b24f18d4550bc4a001bc364e9e4d369504fce0c99e762583d6da267f2f7e5e] Unable to connect to database. Tried 1 times {:error_message=>"Java::JavaSql::SQLRecoverableException: IO Error: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond, Authentication lapse 0 ms."}
[2021-07-22T11:22:42,924][ERROR][logstash.inputs.jdbc ][main][5d2187e4deef8e15edbd453b49ce621da2d805def7d3a2a1a45abb4b261c5a7f] Unable to connect to database. Tried 1 times {:error_message=>"Java::JavaSql::SQLRecoverableException: IO Error: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond, Authentication lapse 0 ms."}
[2021-07-22T11:22:42,943][ERROR][logstash.javapipeline ][main][5d2187e4deef8e15edbd453b49ce621da2d805def7d3a2a1a45abb4b261c5a7f] A plugin had an unrecoverable error. Will restart this plugin.
Pipeline_id:main
Plugin: <LogStash::Inputs::Jdbc jdbc_user=>"<User>", jdbc_paging_enabled=>true, jdbc_password=><password>, statement=>"select<Fields> from <Table>", jdbc_driver_library=>"<Path>/lib/ojdbc8-21.1.0.0.jar", jdbc_connection_string=>"jdbc:oracle:thin:#<HOST>:<PORT>:<SID>", id=>"5d2187e4deef8e15edbd453b49ce621da2d805def7d3a2a1a45abb4b261c5a7f", jdbc_driver_class=>"Java::oracle.jdbc.driver.OracleDriver", type=>"cis-api-gateway-request", enable_metric=>true, codec=><LogStash::Codecs::Plain id=>"plain_00b6436f-afd3-4f1d-8450-d627939f640e", enable_metric=>true, charset=>"UTF-8">, jdbc_page_size=>100000, jdbc_validate_connection=>false, jdbc_validation_timeout=>3600, jdbc_pool_timeout=>5, sql_log_level=>"info", connection_retry_attempts=>1, connection_retry_attempts_wait_time=>0.5, plugin_timezone=>"utc", last_run_metadata_path=>"<Path>/.logstash_jdbc_last_run", use_column_value=>false, tracking_column_type=>"numeric", clean_run=>false, record_last_run=>true, lowercase_column_names=>true, use_prepared_statements=>false>
Error: Java::JavaSql::SQLRecoverableException: IO Error: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond, Authentication lapse 0 ms.
Exception: Sequel::DatabaseConnectionError
Stack: oracle.jdbc.driver.T4CConnection.handleLogonIOException(oracle/jdbc/driver/T4CConnection.java:913)
I am able to connect with the same credentials and connection details through SQL developer.
Here is my Logstash JDBC Input:
jdbc {
jdbc_connection_string => "jdbc:oracle:thin:#<ORACLE_HOST>:<ORACLE_PORT>:<ORACLE_SID>"
jdbc_user => "<USER>"
jdbc_password => "<PASSWORD>"
jdbc_driver_library => "<PATH>/lib/ojdbc8-21.1.0.0.jar"
jdbc_driver_class => "Java::oracle.jdbc.driver.OracleDriver"
jdbc_paging_enabled => true
connection_retry_attempts => 5
connection_retry_attempts_wait_time => 10
statement=> "select<Fields> from <Table>"
type => "<Temp Val>"
}
My Oracle version is 19.3 and Logstash-7.9.1 (windows)
I see that you are using ojdbc8.jar from oracle jdbc driver 21.1 release. Try a simple standalone java test to connect your db and see if you get same error or not. If the issue reproduce then paste the full error stack trace. SQLDeveloper might be using a different release ojdbc jar.
I am trying to send emails using the net/smtp library but I receive the following error message:
SSL_connect returned=1 errno=0 state=unknown state: unknown protocol (OpenSSL::SSL::SSLError)
The code I am using is an extract from Peter Cooper's Beginning Ruby book, modified to use SSL, as required by yahoo servers:
require 'net/smtp'
message = %q{
From: Private Person <me#privacy.net>
To: myself <username#yahoo.com>
Subject: SMTP e-mail test
This is a test e-mail message.
}
smtp = Net::SMTP.new('smtp.mail.yahoo.com', 587)
smtp.enable_ssl
smtp.start('example.org', 'username#yahoo.com', 'password', :login) do |s|
s.send_message message, 'me#privacy.net', 'username#yahoo.com'
end
I tested the above code with Ruby 2.3.1 and Ruby 2.5.1 but I keep receiving the same error message.
By using Net::SMTP#enable_ssl (which is an alias to Net::SMTP#enable_tls), you are instructing the Ruby SMTP client to open a TLS tunnel as the very first step after connecting to the server. This requires the server to also support this on the used server port.
With Yahoos SMTP servers, they support this mode on port 465. With many other providers, you will see that they only support opportunistic TLS on port 587.
What happens there is that the client first starts with plain text SMTP and then negotiates with the server whether they support to update the connection to a TLS tunnel by using the STARTTLS command.
With net/smtp in Ruby, you can use Net::SMTP#enable_starttls instead.
If you are not sure of the server supports STARTTLS and you want to gracefully fallbvack to plaintext transfer of your password and the email to the server, you can also use Net::SMTP#enable_starttls_auto.
Thus, with Yahoo, you have two options:
you can use Net::SMTP#enable_tls on port 465
or you can use Net::SMTP#enable_starttls on port 587
When connecting an external https url, the http proxy server would return the following error:
stream_socket_client(): SSL operation failed with code 1. OpenSSL
Error messages: error:140770FC:SSL
routines:SSL23_GET_SERVER_HELLO:unknown protocol
stream_socket_client(): Failed to enable crypto
stream_socket_client(): unable to connect to ssl://xxx.xxx.xxx:8080
(Unknown error)
It seems cakephp HttpSocket uses the url's scheme to connect the proxy. Can we separate the scheme between proxy and the real destination?
more from the code:
$http_socket = new HttpSocket();
$http_socket->configProxy(array(
'host' => 'xxx.xxx.xxx',
'port' => '8080'
));
$results = $http_socket->post(
'https://yyy.yyy.yyy'
);
hy
i write this code in my script
def connect_sql
Net::SSH.start( #host, #user, :port=>22, :verbose => :debug ) do |ssh|
puts ssh.exec!("./root/scripts/MysqlCleanInstance.sh #{#uid}")
end
end
The probleme is for etablish a conenction between two server we use dns .The DNS information are in /etc/resolv.conf.
i dont know why when i try to connect to another server i get this error:
, [2014-01-08T17:55:34.905977 #28115] DEBUG -- tcpsocket[3f87c7e6b534]: received packet nr 5 type 51 len 44
D, [2014-01-08T17:55:34.906129 #28115] DEBUG -- net.ssh.authentication.session[3f87c7e5b2b0]: allowed methods: publickey,password
D, [2014-01-08T17:55:34.906309 #28115] DEBUG -- net.ssh.authentication.methods.keyboard_interactive[3f87c7e58948]: keyboard-interactive failed
E, [2014-01-08T17:55:34.906487 #28115] ERROR -- net.ssh.authentication.session[3f87c7e5b2b0]: all authorization methods failed (tried none, publickey, hostbased, password, keyboard-interactive)
/var/lib/gems/1.8/gems/net-ssh-2.7.0/lib/net/ssh.rb:215:in `start': Net::SSH::AuthenticationFailed (Net::SSH::AuthenticationFailed)
from clean_instance.rb:87:in `connect_sql'
Make sure your SSH keys are in place. It appears you are not able to authenticate over SSH, even after all authentication methods have been tried.
The reason you are unable to connect to another server is likely because you are not able to authenticate with that other server using a SSH key, which I assume you were able to do with the first server.
I am trying to make a HTTP request using Capybara. When I attempt to execute the code below:
Net::HTTP.get_response(uri)
I get an error:
Errno::ECONNREFUSED: Connection refused - connect(2)
When I try the URI passed into the method explicitly it works perfectly. URL is an absolute address to the localhost starting with http://.
I don't know what I am doing wrong.