Skip to content
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.

Issues with Amazon Alexa Voice Service #225

Closed
sammachin opened this issue Apr 18, 2016 · 20 comments
Closed

Issues with Amazon Alexa Voice Service #225

sammachin opened this issue Apr 18, 2016 · 20 comments

Comments

@sammachin
Copy link

Amazon have released a new API for Alexa but its HTTP/2 only, this is my first attempts with http/2 but there seems to be a problem with accessing the amazon API using hyper, other test servers work fine and I can also connect using curl, I get this error using either hyper on the command line or in a script.
(Token redacted to XXXXX, message me if you need a token to test with)

root@AlexaPiV2:/curl-7.48.0# hyper --debug GET https://avs-alexa-na.amazon.com/v20160207/directives 'Authorization:Bearer XXXXXXXXXXXXXXXX'
Url Info: {'secure': True, 'fragment': None, 'netloc': 'avs-alexa-na.amazon.com', 'host': 'avs-alexa-na.amazon.com', 'query': None, 'path': '/v20160207/directives', 'scheme': 'https', 'port': 443}
Commandline Argument: Namespace(_url='https://avs-alexa-na.amazon.com/v20160207/directives', body=None, debug=True, h2=False, headers={'Authorization': 'Bearer XXXXXXXXXXXX'}, items=[<hyper.cli.KeyValue object at 0x766c45f0>], method='GET', url=<hyper.cli.UrlInfo object at 0x766c4710>)
Selected protocol: None
Traceback (most recent call last):
File "/usr/local/bin/hyper", line 11, in
sys.exit(main())
File "/usr/local/lib/python2.7/dist-packages/hyper/cli.py", line 244, in main
data = request(args)
File "/usr/local/lib/python2.7/dist-packages/hyper/cli.py", line 234, in request
response = conn.get_response()
File "/usr/local/lib/python2.7/dist-packages/hyper/common/connection.py", line 124, in get_response
return self._conn.get_response(_args, *_kwargs)
File "/usr/local/lib/python2.7/dist-packages/hyper/http11/connection.py", line 199, in get_response
response = self.parser.parse_response(self._sock.buffer)
File "/usr/local/lib/python2.7/dist-packages/hyper/http11/parser.py", line 52, in parse_response
version, status, reason = temp_buffer[0:index].split(None, 2)
ValueError: need more than 1 value to unpack
root@AlexaPiV2:
/curl-7.48.0#

@Lukasa
Copy link
Member

Lukasa commented Apr 18, 2016

Thanks for raising this issue!

So it seems like Amazon has done the same as Apple's push notifications service, and only offers ALPN for the negotiation. Your machine seems like it doesn't have a new enough OpenSSL to negotiate with ALPN, so hyper concludes that it can't safely use HTTP/2: Amazon concludes otherwise.

The current development branch has a force_proto kwarg you can use with the API, and should have a --h2 argument for the CLI to force the direct use of HTTP/2. Mind trying those out?

@sammachin
Copy link
Author

Sure, can I just check how to install the dev branch to get the CLI? for this one I just did pip install

@Lukasa
Copy link
Member

Lukasa commented Apr 18, 2016

Sure, run pip install git+https://github.com/Lukasa/hyper.git@development

@sammachin
Copy link
Author

root@AlexaPiV2:~# pip install git+https://github.com/Lukasa/hyper.git@development
Downloading/unpacking git+https://github.com/Lukasa/hyper.git@development
Cloning https://github.com/Lukasa/hyper.git (to development) to /tmp/pip-wcxAmZ-build
Running setup.py (path:/tmp/pip-wcxAmZ-build/setup.py) egg_info for package from git+https://github.com/Lukasa/hyper.git@development
error in hyper setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers
Complete output from command python setup.py egg_info:
error in hyper setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers


Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip-wcxAmZ-build
Storing debug log for failure in /root/.pip/pip.log
root@AlexaPiV2:~# cat /root/.p
.pip/ .profile

root@AlexaPiV2:~# cat /root/.pip/pip.log

/usr/bin/pip run on Mon Apr 18 10:49:43 2016
Downloading/unpacking git+https://github.com/Lukasa/hyper.git@development
Cloning https://github.com/Lukasa/hyper.git (to development) to /tmp/pip-wcxAmZ-build
Found command 'git' at '/usr/bin/git'
Running command /usr/bin/git clone -q https://github.com/Lukasa/hyper.git /tmp/pip-wcxAmZ-build
Running command /usr/bin/git show-ref
db66a7a refs/heads/development
db66a7a refs/remotes/origin/HEAD
7e671d0 refs/remotes/origin/concurrency
db66a7a refs/remotes/origin/development
fd6bade refs/remotes/origin/master
e0b4efc refs/remotes/origin/state
62b1cf5 refs/tags/v0.0.2
3c8ae0d refs/tags/v0.0.3
ec527e872af38f4fc83dea02d17d63f8b5ec60fe refs/tags/v0.0.4
308be18 refs/tags/v0.1.0
05cfc21 refs/tags/v0.1.1
8d1eb85 refs/tags/v0.1.2
951756c refs/tags/v0.2.0
c5775cb refs/tags/v0.2.1
d374985 refs/tags/v0.2.2
b4ca99e refs/tags/v0.3.0
e4f57e7 refs/tags/v0.3.1
7202f24 refs/tags/v0.4.0
fd6bade refs/tags/v0.5.0
Running command /usr/bin/git rev-parse HEAD
db66a7a
Running setup.py (path:/tmp/pip-wcxAmZ-build/setup.py) egg_info for package from git+https://github.com/Lukasa/hyper.git@development
error in hyper setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers
Complete output from command python setup.py egg_info:
error in hyper setup command: 'install_requires' must be a string or list of strings containing valid project/version requirement specifiers


Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip-wcxAmZ-build
Exception information:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 290, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 1230, in prepare_files
req_to_install.run_egg_info()
File "/usr/lib/python2.7/dist-packages/pip/req.py", line 326, in run_egg_info
command_desc='python setup.py egg_info')
File "/usr/lib/python2.7/dist-packages/pip/util.py", line 716, in call_subprocess
% (command_desc, proc.returncode, cwd))
InstallationError: Command python setup.py egg_info failed with error code 1 in /tmp/pip-wcxAmZ-build

@Lukasa
Copy link
Member

Lukasa commented Apr 18, 2016

What pip version do you have? Seems like it can't handle the pip version specifiers being used.

@sammachin
Copy link
Author

root@AlexaPiV2:~# pip -V

pip 1.5.6 from /usr/lib/python2.7/dist-packages (python 2.7)

I'm running on a RaspberryPi with the latest Raspian build

On Mon, Apr 18, 2016 at 12:10 PM, Cory Benfield [email protected]
wrote:

What pip version do you have? Seems like it can't handle the pip version
specifiers being used.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#225 (comment)

@Lukasa
Copy link
Member

Lukasa commented Apr 18, 2016

Yeah, pip 1.5.6 is quite old. This might be fixable on the development branch but I'm currently on my phone at an airport so I can't check until later. In the meantime, if you're familiar with virtualenv you can create one of those and then upgrade pip inside it (pip -U pip) then try the install.

@sammachin
Copy link
Author

Thanks, I'll have a play later, should get back to the day job! have a good
flight

On Mon, Apr 18, 2016 at 12:30 PM, Cory Benfield [email protected]
wrote:

Yeah, pip 1.5.6 is quite old. This might be fixable on the development
branch but I'm currently on my phone at an airport so I can't check until
later. In the meantime, if you're familiar with virtualenv you can create
one of those and then upgrade pip inside it (pip -U pip) then try the
install.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#225 (comment)

@sammachin
Copy link
Author

sammachin commented Apr 19, 2016

Got the dev branch installed in a venv, however now I'm getting a new error:
(newpip) root@AlexaPiV2:~/newpip# hyper --debug --h2 GET https://avs-alexa-na.amazon.com/v20160207/directives 'Authorization:Bearer XXXX'
Url Info: {'secure': True, 'fragment': None, 'netloc': 'avs-alexa-na.amazon.com', 'host': 'avs-alexa-na.amazon.com', 'query': None, 'path': '/v20160207/directives', 'scheme': 'https', 'port': 443} Commandline Argument: Namespace(_url='https://avs-alexa-na.amazon.com/v20160207/directives', body=None, debug=True, h2=True, headers={'Authorization': 'Bearer XXXX'}, items=[<hyper.cli.KeyValue object at 0x7653f090>], method='GET', url=<hyper.cli.UrlInfo object at 0x76518990>) Selected NPN protocol: None Traceback (most recent call last): File "/root/newpip/bin/hyper", line 9, in <module> load_entry_point('hyper==0.5.0', 'console_scripts', 'hyper')() File "/root/newpip/local/lib/python2.7/site-packages/hyper/cli.py", line 251, in main data = request(args) File "/root/newpip/local/lib/python2.7/site-packages/hyper/cli.py", line 240, in request conn.request(args.method, args.url.path, args.body, args.headers) File "/root/newpip/local/lib/python2.7/site-packages/hyper/http20/connection.py", line 178, in request self.endheaders(message_body=body, final=True, stream_id=stream_id) File "/root/newpip/local/lib/python2.7/site-packages/hyper/http20/connection.py", line 367, in endheaders self.connect() File "/root/newpip/local/lib/python2.7/site-packages/hyper/http20/connection.py", line 251, in connect assert proto in H2_NPN_PROTOCOLS or proto == H2C_PROTOCOL AssertionError

@Lukasa
Copy link
Member

Lukasa commented Apr 19, 2016

Ah, yes. Ok, that's a real bug. I'll take a swing at it in the next 24 hours: should be an easy fix.

@sammachin
Copy link
Author

oh cool thanks :)

On Tue, Apr 19, 2016 at 8:13 PM, Cory Benfield [email protected]
wrote:

Ah, yes. Ok, that's a real bug. I'll take a swing at it in the next 24
hours: should be an easy fix.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#225 (comment)

@Lukasa
Copy link
Member

Lukasa commented Apr 20, 2016

@sammachin I believe I've fixed this: want to try again with the new tip?

@nicholasjconn
Copy link

I've been following this thread since its inception, and I'm happy to say that hyper is now working just fine with Amazon's AVS.

Thanks for actively developing hyper and keeping up on this kind of stuff! It is much appreciated.

@Lukasa
Copy link
Member

Lukasa commented Apr 21, 2016

@nicholasjconn Happy to do it! I've got a release of hyper-h2 upcoming: when I've shipped that, I should have some time to spare to get this library into shape for a new release.

@sammachin
Copy link
Author

Yep seems to be working, thanks for sorting this so quickly :)

Now to try and decipher the rest of this AVS api!

@joshdover
Copy link

Correct me if I'm wrong, but if I'm using hyper with the requests adapter, it seems there's no way to to set the force_proto option? What openssl packages do I need to change on my machine to just make this work without that option?

@Lukasa
Copy link
Member

Lukasa commented Sep 4, 2016

Correct; that work is sitting in #214 and is as-yet unfinished. To get this to work without that option you'll need OpenSSL 1.0.2. What OS are you using?

@joshdover
Copy link

I'm on raspbian (debian) jessie, having a hard time finding a package for it. Might just trying to build it unless you have any tips.

@joshdover
Copy link

Hm, installed openssl 1.0.2h from debian/testing and I'm still getting the same error. Tried recompiling python 3.5 as well. Any ideas?

@Lukasa
Copy link
Member

Lukasa commented Sep 5, 2016

@joshdover To be clear, what error are you getting? Also, can you please confirm that the Python you're using is linked against your new OpenSSL? python -c "import ssl; print ssl.OPENSSL_VERSION".

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants