每次我尝试使用erlcloud_sns(亚马逊SNS)时都会出错
erlcloud_sns:list_topics_all().
erlcloud_sns:create_topic("Topic2fromerlConsole").
erlcloud_sns:publish_to_topic("arn:aws:sns:eu-west-1:XXXXXXXXXXXX:AuTopic" , "my message", "subj").
我收到一个错误
** exception error: {sns_error,{socket_error,{nxdomain,[{lhttpc_client,send_request, 1, [{file,"src/lhttpc_client.erl"},{line,222}]}, {lhttpc_client,execute,9, [{file,"src/lhttpc_client.erl"},{line,171}]}, {lhttpc_client,request,9, [{file,"src/lhttpc_client.erl"},{line,93}]}]}}}
in function erlcloud_sns:sns_xml_request/3 (src/erlcloud_sns.erl, line 574)
in call from erlcloud_sns:create_topic/2 (src/erlcloud_sns.erl, line 153)
ssl已启动,sns已成功配置
更新:
在我的域名fix之后,我收到错误"永久移动"
erlcloud_sns:publish_to_topic("arn:aws:sns:eu-west-1:XXXXXXXXXXXX:AuTopic" , "my message", "subj")..
Error: [lhttpc_client,211,"eu-west-1.console.aws.amazon.com",80,
[binary,{packet,http},{active,false}],
infinity,false]
** exception error: {sns_error,{http_error,301,"Moved Permanently",
<<"<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\n<html><head>\n<title>301 Moved Permanently"...>>}}
in function erlcloud_sns:sns_xml_request/3 (src/erlcloud_sns.erl, line 574)
in call from erlcloud_sns:list_topics/2 (src/erlcloud_sns.erl, line 299)
in call from erlcloud_sns:list_all/5 (src/erlcloud_sns.erl, line 594)
如何让erlcloud sns工作?任何建议都会有所帮助
s3的错误301在url名称中,但error codes
中的sns没有更新-2
固定: 我指定了不正确的主机(&#34; sns.eu-west-1.console.aws.amazon.com&#34;)而不是&#34; sns.eu-west-1.amazonaws.com&#34;(正确的) )
答案 0 :(得分:1)
遇到类似的问题,经过一些挖掘后我发现它使用的是sns.amazonaws.com的默认主机,这是无法解析的。覆盖特定于地区的主机名,例如&sns.us-west-2.amazonaws.com&#39; (或基于您的发布示例的eu-west-1)解决它。在进行配置时,请务必使用configure / 3来提供主机名。我使用Elixir的erlcloud,所以我的简单例子是:
sns_host = "sns.us-west-2.amazonaws.com" |> String.to_char_list
:erlcloud_sns.configure(access_key_id, secret_access_key, sns_host)
...最终允许我的list_topics返回有效信息,而不是nxdomain错误。希望这会有所帮助。