【问题标题】:Could not able to subscribe the topic by django http endpoint无法通过 django http 端点订阅主题
【发布时间】:2020-06-27 17:02:40
【问题描述】:

我尝试了很多。我关注了https://docs.aws.amazon.com/sns/latest/dg/sns-http-https-endpoint-as-subscriber.html这个帖子 还将我的 ec2 安全组入站更改为任何 http 端口 80。

我也从How can i confirm the subscription request HTTP from amazon SNS 的类似问题中得到了帮助 也在这里 Cannot get HTTP subscription confirmation request

在views.py中

def unsub(request):
    content = ""
    if request.POST:
        json1 = request.body.decode('utf-8')
        print(json1)
        f = open('home/json.py','w')
        f.write(json1)
        f.close()

    f = open('home/json.py','r')
    content = f.read()
    f.close()
    return render(request,'home/json.html',{'content':content})

在 urls.py 中

 urlpatterns = [
     path('unsub2',views.unsubscribe,name="unsubscribe"), 
 ]

这是我的 json.html,

<html>
 <head>
 </head>
 <body>
  <p>{{content|safe}}</p>
   <form method="post">
     <input type="text" name="i1" id="i1"></input>
     <input type="text" name="i2" id="i2"></input>
     <button type="submit" >submit</button>
   </form>
  </body></html>

我已将 sns 主题订阅到 http 端点 http://my-ec2-domain.com/unsub2,但我没有收到对该页面的任何响应,也没有任何日志。请告诉我哪里做错了。 python 3.5 django 2.1.

【问题讨论】:

    标签: django python-3.x amazon-sns subscription


    【解决方案1】:

    我想通了。虽然我更改了实例的安全组设置,但我忘记在允许的主机设置中添加 SNS 服务 ip。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-01-11
      • 2016-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-27
      • 2017-04-20
      相关资源
      最近更新 更多