遇到问题我一直在抨击 - 我在我的机器上运行的Crystal HTTP客户端有一个GET请求,并且在编译容器 - crystallang / crystal上得到了一个很好的响应,它的工作。
但是将相同的二进制文件移动到任何其他环境(alpine / ubuntu)它只是赢了,这个例外对我来说没有意义; 我通过TCP(Socket :: Error)"找到了一个奇怪的"没有找到api.example.com:443的地址。 无法理解我做错了什么。 尝试添加ca证书,甚至将整个ssl dir复制到我的容器中。没运气... 这是代码:
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 ???
答案 0 :(得分:0)
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