gpt4 book ai didi

Ruby:Sinatra:Web 服务在 Thin 上不可访问

转载 作者:太空宇宙 更新时间:2023-11-03 16:50:27 24 4
gpt4 key购买 nike

我在瘦网络服务器上的 centOS 中运行了一个 ruby​​ sinatra 网络服务。我无法使用 210.71.253.59:3001/swap 远程连接到它。 (它确实在本地主机上工作),一切似乎都很好:

-bash-4.1$ ruby spotify_token_swap.rb 
== Sinatra/1.4.5 has taken the stage on 3001 for development with backup from Thin
Thin web server (v1.6.2 codename Doc Brown)
Maximum connections set to 1024
Listening on 210.71.253.59:3001, CTRL+C to stop

我已验证 3001 端口已打开。(我看过类似的帖子Ruby Sinatra Webservice running on localhost:4567 but not on IP,还是无法解决)

关于原因的任何想法,或者我做错了什么?这是我的 .rb:

require 'rubygems'
require 'sinatra'
require 'net/http'
require 'net/https'

set :bind, '210.71.253.59'
set :port, 3001

post '/swap' do

auth_code = params[:code]

uri = URI.parse("https://ws.spotify.com")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new("/oauth/token")
request.form_data = {
"grant_type" => "authorization_code",
"client_id" => kClientId,
"client_secret" => kClientSecret,
"redirect_uri" => kClientCallbackURL,
"code" => auth_code
}

response = http.request(request)

status response.code.to_i
return response.body

end

最佳答案

以防万一有人遇到同样的问题:

其实很简单...不要忘记检查 iptables,在我的例子中它阻止了传入连接。

关于Ruby:Sinatra:Web 服务在 Thin 上不可访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23540496/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com