[英]Resque Job can't connect to localhost to POST request
我的Resque Job無法連接到localhost以發出POST請求...
當我嘗試UserCreatorJob.perform_now(options)
它運行正常。
當我使用UserCreatorJob.perform_later(options)
它進入resque隊列,然后在執行時失敗, Connection refused - connect(2) for "fe80::1%lo0" port 3000
user_creator_job.rb
class UserCreatorJob < Jobs::ApplicationJob
queue_as :user
def perform(*args)
conn :post, 'api/v1/users', args
end
def conn
Faraday.new(url: 'http://localhost:3000') do |faraday|
faraday.request :url_encoded # form-encode POST params
faraday.response :logger # log requests to STDOUT
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
faraday.token_auth('')
end
end
end
如果我使用CURL進行發布,一切都會按預期進行。
我認為resque可能不喜歡發布到本地主機。
嘗試將此行添加到您的/ etc / hosts文件中:
127.0.0.1 my.api.dev
然后,在您的代碼中,將http:// localhost:3000替換為http://my.api.dev:3000
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.