收藏
回答

无法连接api.weixin.qq.com

框架类型 问题类型 API/组件名称 终端类型 微信版本 基础库版本
小程序 Bug auth.code2Session 微信iOS客户端 未知 未知

https://developers.weixin.qq.com/miniprogram/dev/api/open-api/login/wx.login.html

服务端Python写的,请求api.weixin.qq.com的时候,时不时的会报错,无法连接:

Python代码如下:

    # 微信登陆
    openid_url = "https://api.weixin.qq.com/sns/jscode2session?appid=%s&secret=%s&js_code=%s&grant_type=authorization_code" % (
        settings.MINIAPP_SETTING.get(apiuser.app_id), settings.MINIAPP_SETTING.get(apiuser.app_key), code
    )
    req = requests.get(openid_url,verify=False)


错误1:

ConnectionError: HTTPSConnectionPool(host='api.weixin.qq.com', port=443): Max retries exceeded with url: /sns/jscode2session?appid=xxxxxxx&secret=xxxxxxx&js_code=xxxxx&grant_type=authorization_code (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7fad486bb3d0>: F

ailed to establish a new connection: [Errno 111] Connection refused',))

错误2:

SSLError: HTTPSConnectionPool(host='api.weixin.qq.com', port=443): Max retries exceeded with url: /sns/jscode2session?appid=xxxxxxx&secret=xxxxxxx

&js_code=xxxxxxx&grant_type=authorization_code (Caused by SSLError(SSLError("bad handshake: SysCallError(-1, 'Unexpected EOF')",),))  

错误3:

ConnectionError: ('Connection aborted.', BadStatusLine("''",))



回答关注问题邀请回答
收藏

1 个回答

  • 藤井树
    藤井树
    2020-06-19

    有没有证书?ssl 证书?配置好了?

    2020-06-19
    有用
    回复 1
登录 后发表内容
问题标签