有一个问题,我正在抨击 - 我有一个 GET 请求与 Crystal HTTP 客户端,它在我的机器上运行,也在编译容器 - crystallang/crystal 上,得到很好的响应并完成它的工作。
但是将相同的二进制文件移动到任何其他环境(alpine/ubuntu(它就是不会,而且例外对我来说没有意义;我收到一个奇怪的"找不到通过TCP api.example.com:443 的地址(套接字::错误("不知道我做错了什么。尝试添加 ca 证书,甚至将整个 ssl 目录复制到我的容器中。没有运气...代码如下:
def createTag(vtag)
if vtag.key.empty? || vtag.application.empty? || vtag.subsystem.empty? || vtag.name.empty?
raise PluginException.new("One of the parameters are empty")
end
if vtag.timestamp.empty?
vtag.timestamp = Time.now.to_s("%Y-%m-%d:%H:%M:%S")
end
params = "/api/v1/addTag?key=#{vtag.key}&application=#{vtag.application}&subsystem=#{vtag.subsystem}&name=#{vtag.name}×tamp=#{vtag.timestamp}"
response = HTTP::Client.new("api.coralogix.com", tls: true).get(params)
puts response.body
puts response.status_code
end
这是在 ubuntu 上运行编译二进制文件的错误:
No address found for api.coralogix.com:443 over TCP (Socket::Error)
from usr/share/crystal/src/string.cr:4193:13 in 'socket'
from usr/share/crystal/src/http/client.cr:500:19 in 'exec_internal_single'
from usr/share/crystal/src/http/client.cr:486:16 in '???'
from usr/share/crystal/src/crystal/main.cr:0:3 in 'main'
from ???
from ???
from ???
使用 HTTP:Client.get
def createTag(vtag)
if vtag.key.empty? || vtag.application.empty? || vtag.subsystem.empty? || vtag.name.empty?
raise PluginException.new("One of the parameters are empty")
end
if vtag.timestamp.empty?
vtag.timestamp = Time.now.to_s("%Y-%m-%d:%H:%M:%S")
end
params = "api/v1/addTag?key=#{vtag.key}&application=#{vtag.application}&subsystem=#{vtag.subsystem}&name=#{vtag.name}×tamp=#{vtag.timestamp}"
response = HTTP::Client.get("https://api.coralogix.com/#{params}")
puts response.body
puts response.status_code
end