Reputation: 2807
I recently integrated Tencent's translation API. Everything works fine on my development machine, but I am having trouble making a POST request from my Heroku server.
SocketError (Failed to open TCP connection to tmt.tencentcloudapi.com:443 (getaddrinfo: Temporary failure in name resolution))
The question I have is who's problem is causing this issue? Heroku or Tencent?
UPDATING POST w/ code:
host = "tmt.tencentcloudapi.com"
endpoint = "https://" + host
uri = URI.parse(endpoint)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(endpoint, {'Content-Type' => 'application/json; charset=utf-8', 'Authorization' => authorization, 'Host' => host, 'X-TC-Action' => action, 'X-TC-Version' => version, 'X-TC-Timestamp' => timestamp.to_s, 'X-TC-Region' => region })
req.body = params
res = http.request(req)
Upvotes: 4
Views: 11431
Reputation: 2807
As per Tencent's API documentation https://cloud.tencent.com/document/api/551/15614
I use tmt.na-siliconvalley.tencentcloudapi.com
instead of tmt.tencentcloudapi.com
Upvotes: 0
Reputation: 96
Your question asks "who's problem is causing this issue?" and propose two culprits--let me propose a third (and likely) culprit: The Great Firewall of China.
Heroku runs on AWS, which is sometimes by the Chinese government. Heroku itself may also be subject to blockage by the Chinese government, depending on the time of day, month, year, and if any sensitive internal political activity is happening. This is all very hard to predict.
I did come across this blog post, which claims that Heroku is blocked in China: https://alexbosworth.net/post/13244162414/should-i-use-heroku
Heroku Apps are blocked in China - I live in China, I want a service that isn’t blocked here. China is projected to become the biggest economy in the world within 5 years, it’s an important market.
Given how DNS resolutions work (and be default, is unencrypted), the Great Firewall performs DPI (deep packet inspection) on any incoming and outgoing packets. When it sees a return IP address that is in the blocked range (e.g. Heroku's IP block), then the Great Firewall will block any packets from exiting China and reaching your US-based Heroku instance.
This would explain why, if all authoritative servers for Tencent is in China, and Heroku is blocked, then your DNS resolution can fail.
Upvotes: 2