respeaker / avs

python implementation of alexa voice service app, 支持DuerOS
Other
197 stars 63 forks source link

AttributeError: 'Response' object has no attribute 'status' #46

Open Tonemon opened 3 years ago

Tonemon commented 3 years ago

Description

Hi, I just picked up this project after a while and I am trying to make this script working on boot. I started with the information from #26 where @xiongyihui said to add it to the autorun.sh file.

What I Did

echo "run_alexa.sh: Starting 5 sec sleep process..." > /dev/console sleep 5

echo "run_alexa.sh: done sleeping, running alexa in screen: sleepyalexa..." > /dev/console echo "run_alexa.sh: to access this screen, type screen -r" > /dev/console screen -dm -S sleepyalexa ash -c "alexa"


A new screen is being created at boot with the 'alexa' command and the light ring lights up, but after I say something, the ```alexa.py``` script crashes and it loops on this error:

WARNING:avs.alexa:{"error_description":"The request has an invalid grant parameter : refresh_token","error":"invalid_grant"} WARNING:avs.alexa:{"error_description":"The request has an invalid grant parameter : refresh_token","error":"invalid_grant"} ERROR:avs.alexa:'Response' object has no attribute 'status' Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/avs/alexa.py", line 110, in run self._run() File "/usr/lib/python2.7/site-packages/avs/alexa.py", line 129, in _run headers = {'authorization': 'Bearer {}'.format(self.token)} File "/usr/lib/python2.7/site-packages/avs/alexa.py", line 360, in token "refresh token request returned {}".format(response.status)) AttributeError: 'Response' object has no attribute 'status' INFO:avs.alexa:Refreshing access_token WARNING:avs.alexa:{"error_description":"The request has an invalid grant parameter : refresh_token","error":"invalid_grant"} INFO:requests.packages.urllib3.connectionpool:Resetting dropped connection: api.amazon.com WARNING:avs.alexa:{"error_description":"The request has an invalid grant parameter : refresh_token","error":"invalid_grant"} WARNING:avs.alexa:{"error_description":"The request has an invalid grant parameter : refresh_token","error":"invalid_grant"} ERROR:avs.alexa:'Response' object has no attribute 'status' Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/avs/alexa.py", line 110, in run self._run() File "/usr/lib/python2.7/site-packages/avs/alexa.py", line 129, in _run headers = {'authorization': 'Bearer {}'.format(self.token)} File "/usr/lib/python2.7/site-packages/avs/alexa.py", line 360, in token "refresh token request returned {}".format(response.status)) AttributeError: 'Response' object has no attribute 'status' INFO:avs.alexa:Refreshing access_token WARNING:avs.alexa:{"error_description":"The request has an invalid grant parameter : refresh_token","error":"invalid_grant"} INFO:requests.packages.urllib3.connectionpool:Resetting dropped connection: api.amazon.com WARNING:avs.alexa:{"error_description":"The request has an invalid grant parameter : refresh_token","error":"invalid_grant"} WARNING:avs.alexa:{"error_description":"The request has an invalid grant parameter : refresh_token","error":"invalid_grant"} ERROR:avs.alexa:'Response' object has no attribute 'status' Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/avs/alexa.py", line 110, in run self._run() File "/usr/lib/python2.7/site-packages/avs/alexa.py", line 129, in _run headers = {'authorization': 'Bearer {}'.format(self.token)} File "/usr/lib/python2.7/site-packages/avs/alexa.py", line 360, in token "refresh token request returned {}".format(response.status)) AttributeError: 'Response' object has no attribute 'status'



Some notes:
- I can start a new screen from SSH just fine (with ```screen ash -c "alexa"```) and deattach from it. Alexa keeps working and I can reattach to it whenever I want.
- I can start a detached screen from SSH just fine (with ```screen -dm -S sleepyalexa ash -c "alexa"```) and Alexa keeps working in the background.

I just can't get it to start at boot without the error above. Does someone know how to fix it?
Tonemon commented 3 years ago

INFO:requests.packages.urllib3.connectionpool:Resetting dropped connection: api.amazon.com

After looking a bit closer in the code and errors I noticed that the connections to api.amazon.com are somehow being dropped and because of that, it does not receive a response, which causes this error. I find it weird that connections are being dropped when starting alexa in a detached screen at boot, but it works just fine when you start it via a SSH connection.

I get the following INFO message when running from a SSH connection:

INFO:requests.packages.urllib3.connectionpool:Starting new HTTPS connection (1): api.amazon.com

Does someone know how to fix it?