python-hyper / hyper

HTTP/2 for Python.
http://hyper.rtfd.org/en/latest/
MIT License
1.05k stars 191 forks source link

In raspberry(python3.4) , raise ConnectionResetError #382

Open moxigua opened 6 years ago

moxigua commented 6 years ago
Traceback (most recent call last):
  File "/home/pi/Public/DuerOS-Python-Client-moxigua/sdk/dueros_core.py", line 178, in run
    self.__run()
  File "/home/pi/Public/DuerOS-Python-Client-moxigua/sdk/dueros_core.py", line 205, in __run
    downchannel_response = conn.get_response(downchannel_id)
  File "/usr/local/lib/python3.4/dist-packages/hyper/http20/connection.py", line 312, in get_response
    return HTTP20Response(stream.getheaders(), stream)
  File "/usr/local/lib/python3.4/dist-packages/hyper/http20/stream.py", line 230, in getheaders
    self._recv_cb(stream_id=self.stream_id)
  File "/usr/local/lib/python3.4/dist-packages/hyper/http20/connection.py", line 771, in _recv_cb
    self._single_read()
  File "/usr/local/lib/python3.4/dist-packages/hyper/http20/connection.py", line 665, in _single_read
    self._sock.fill()
  File "/usr/local/lib/python3.4/dist-packages/hyper/common/bufsocket.py", line 169, in fill
    raise ConnectionResetError()
ConnectionResetError

and my code is :

` conn = hyper.HTTP20Connection('{}:443'.format(self.__config['host_url']), force_proto='h2')

headers = {'authorization': 'Bearer {}'.format(self.token)} if 'dueros-device-id' in self.config: headers['dueros-device-id'] = self.config['dueros-device-id']

downchannel_id = conn.request('GET', '/{}/directives'.format(self.__config['api']), headers=headers) downchannel_response = conn.get_response(downchannel_id)

if downchannel_response.status != 200: raise ValueError("/directive requests returned {}".format(downchannel_response.status))

ctype, pdict = cgi.parse_header(downchannel_response.headers['content-type'][0].decode('utf-8')) downchannel_boundary = '--{}'.format(pdict['boundary']).encode('utf-8') downchannel = conn.streams[downchannel_id] downchannel_buffer = io.BytesIO() eventchannel_boundary = 'baidu-voice-engine'

`