python
  • google-app-engine
  • python-requests
  • 2016-11-09 54 views 1 likes 
    1

    が、私はこのエラーに
    ChunkedEncodingErrorを取得しています:( '壊れた接続:IncompleteRead(14バイトリード)'、IncompleteRead(14バイトリード))
    は、私が "リクエスト" からPOSTリクエストを作っていますライブラリ(サードパーティ)をPythonを使ってGoogle App Engineに追加しました。
    ChunkedEncodingErrorはどのように修正する必要がありますか?

    url = 'https://fcm.googleapis.com/fcm/send' 
         body = { 
          "data": { 
           "title": "data:mytitle", 
           "body": "data:mybody", 
           "url": "data:myurl" 
          }, 
          "notification": { 
           "title": "noti:My web app name", 
           "body": "noti:message", 
           "content_available": "noti:true" 
          }, 
          "message": "test", 
          "registration_ids": ["xxxxxxxxxxxxxxxxxxxx"] 
         } 
         headers = {"Content-Type": "application/json", 
            "Authorization": "key=xxxxxxxxxxxxxxxx"} 
    
         logging.error(json.dumps(body)) 
         requests.post(url, data=json.dumps(body), headers=headers) 
    

    答えて

    2

    Google App Engineを持つ問題は、1が「要求」と一人で働くことができないということで、我々はまた、それに伴い、「リクエスト・ツールベルト」を使用する必要があります。

    ステップ1:内部では、この問題を修正します

    import requests_toolbelt.adapters.appengine 
    
    requests_toolbelt.adapters.appengine.monkeypatch() 
    


    を追加をmain.py:LIB APPDIR/
    https://cloud.google.com/appengine/docs/python/tools/using-libraries-python-27#installing_a_library


    ステップ2にリクエスト・ツールベルトを追加します。

    +0

    これは正しいです。 [Requesting HTTP(S)Requests](https://cloud.google.com/appengine/docs/standard/python/issue-requests#issuing_an_http_request)のドキュメントでは、** requests - toolbelt **を含めて、 **要求**ライブラリは、デフォルトのソケットの代わりに** URLのフェッチ**を使用します。 – Nicholas

    +0

    これは機能します!私はgspreadを使ってシートを読み込もうとしていて、ChunkedEncodingErrorの問題に直面していました。今解決されました!ありがとう:) –

    1

    私はこの問題があり、PyFCMを使用しました。すべてがうまくいった。あなたがそれを使用する場合は、バージョン1.2.8以降をインストールしてください。その下のバージョンでは、同じ問題が発生します

    関連する問題