【问题标题】:Different behavior of TCPSocket [duplicate]TCPSocket的不同行为[重复]
【发布时间】:2016-06-26 15:06:08
【问题描述】:

我的一个 Rails 应用程序开发存在问题。我使用heroku 来部署我的rails 应用程序(prod env)。而且我在 dev 和 prod 环境之间存在误解。

当我在 dev env 的 rails 控制台(rails 控制台,在我的本地计算机上)和 heroku 的 rails 命令中的相同命令(heroku运行 rails 控制台),我没有相同的结果。

在开发环境中,我得到“#TCPSocket:fd 18”,然后没有出现问题,但在产品环境中,我得到“Errno::ECONNREFUSED: Connection denied - connect(2) for nil port 80”

来自 (irb):1:in initialize' from (irb):1:innew'

来自 (irb):1

来自 /app/vendor/bundle/ruby/2.3.0/gems/railties 4.2.5/lib/rails/commands/console.rb:110:in `start'

来自 /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.5/lib/rails/commands/console.rb:9:in `start'

来自 /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:68:in `console'

来自 /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!'

来自 /app/vendor/bundle/ruby/2.3.0/gems/railties-4.2.5/lib/rails/commands.rb:17:in `'

来自 /app/bin/rails:9:in `require'

来自 /app/bin/rails:9:in main "

我有相同的环境(相同版本的 ruby​​、rails 等...) 所以,如果你们中的一个人之前已经遇到过这个问题,或者可以解释一下 TCPSocket 在这种情况下的行为。

提前谢谢你。

【问题讨论】:

  • 我解决了我的问题,这是因为我已经在 localhost 的端口 80 上运行了一些东西,而不是在 prod env 中!所以要小心你的端口!并感谢大家的回复。

标签: ruby-on-rails ruby heroku


【解决方案1】:

您的 config/production.rb 邮件程序看起来像这样吗?

 config.action_mailer.raise_delivery_errors = true
  config.action_mailer.delivery_method = :smtp
  host = 'yoursubdomain.herokuapp.com'
  config.action_mailer.default_url_options = { host: host }
  ActionMailer::Base.smtp_settings = {
    :address        => 'smtp.sendgrid.net',  //or whichever u use 
    :port           => '587',
    :authentication => :plain,
    :user_name      => ENV['SENDGRID_USERNAME'],
    :password       => ENV['SENDGRID_PASSWORD'],
    :domain         => 'heroku.com',
    :enable_starttls_auto => true
  }

结束

【讨论】:

猜你喜欢
  • 2017-11-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-02-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-12-05
相关资源
最近更新 更多