audiokinetic / waapi-client-python

Decoupled autobahn WAMP client with support for plain options and bindable subscription callbacks
Apache License 2.0
41 stars 6 forks source link

Sample code stopped working on macOS Catalina #8

Closed kakyoism closed 3 years ago

kakyoism commented 3 years ago

My Setup

Repro

^CTraceback (most recent call last):
  File "/Applications/Audiokinetic/Wwise_2019.2.7/SDK/samples/WwiseAuthoringAPI/python/waapi-client-py3/rpc.py", line 7, in <module>
    with WaapiClient() as client:
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/waapi/client/client.py", line 77, in __init__
    if not self.__connect():
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/waapi/client/client.py", line 94, in __connect
    self._decoupler.wait_for_joined()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/waapi/wamp/ak_autobahn.py", line 35, in wait_for_joined
    self._joined_event.wait()
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 574, in wait
    signaled = self._cond.wait(timeout)
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 312, in wait
    waiter.acquire()
KeyboardInterrupt
^CException ignored in: <module 'threading' from '/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py'>
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 1424, in _shutdown
    lock.acquire()
KeyboardInterrupt: 

Attempts

The attempts below don't affect the results above.

$ pip3 install --upgrade autobahn
Requirement already satisfied: autobahn in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (20.12.3)
Collecting autobahn
  Downloading autobahn-21.3.1-py2.py3-none-any.whl (495 kB)
     |████████████████████████████████| 495 kB 465 kB/s 
Collecting cryptography>=3.4.6
  Downloading cryptography-3.4.6-cp36-abi3-macosx_10_10_x86_64.whl (2.0 MB)
     |████████████████████████████████| 2.0 MB 689 kB/s 
Collecting txaio>=21.2.1
  Downloading txaio-21.2.1-py2.py3-none-any.whl (30 kB)
Requirement already satisfied: hyperlink>=21.0.0 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from autobahn) (21.0.0)
Requirement already satisfied: cffi>=1.12 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from cryptography>=3.4.6->autobahn) (1.14.4)
Requirement already satisfied: pycparser in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from cffi>=1.12->cryptography>=3.4.6->autobahn) (2.20)
Requirement already satisfied: idna>=2.5 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages (from hyperlink>=21.0.0->autobahn) (2.10)
Installing collected packages: txaio, cryptography, autobahn
  Attempting uninstall: txaio
    Found existing installation: txaio 20.12.1
    Uninstalling txaio-20.12.1:
      Successfully uninstalled txaio-20.12.1
  Attempting uninstall: cryptography
    Found existing installation: cryptography 3.3.1
    Uninstalling cryptography-3.3.1:
      Successfully uninstalled cryptography-3.3.1
  Attempting uninstall: autobahn
    Found existing installation: autobahn 20.12.3
    Uninstalling autobahn-20.12.3:
      Successfully uninstalled autobahn-20.12.3
Successfully installed autobahn-21.3.1 cryptography-3.4.6 txaio-21.2.1
$ py3 "/Applications/Audiokinetic/Wwise 2019.2.9/SDK/samples/WwiseAuthoringAPI/python/low-level/hello-wwise-http/main.py"
200 OK
b'{"displayName":"Wwise","platform":"x64","version":{"displayName":"v2019.2.7","year":2019,"major":2,"minor":7,"build":7402,"nickname":"","schema":97},"apiVersion":1,"branch":"wwise_v2019.2","copyright":"(C) 2006-2020. Audiokinetic Inc. All rights reserved.","configuration":"release","isCommandLine":false,"processId":34,"processPath":"c:\\\\Program Files\\\\Audiokinetic\\\\Wwise 2019.2.7.7402\\\\Authoring\\\\x64\\\\Release\\\\bin\\\\Wwise.exe","directories":{"log":"c:\\\\Program Files\\\\Audiokinetic\\\\Wwise 2019.2.7.7402\\\\Authoring\\\\x64\\\\Release\\\\bin\\\\Logs\\\\","user":"Y:\\\\Library\\\\Application Support\\\\Audiokinetic\\\\Wwise","install":"c:\\\\Program Files\\\\Audiokinetic\\\\Wwise 2019.2.7.7402\\\\","authoring":"c:\\\\Program Files\\\\Audiokinetic\\\\Wwise 2019.2.7.7402\\\\Authoring\\\\","bin":"c:\\\\Program Files\\\\Audiokinetic\\\\Wwise 2019.2.7.7402\\\\Authoring\\\\x64\\\\Release\\\\bin\\\\","help":"c:\\\\Program Files\\\\Audiokinetic\\\\Wwise 2019.2.7.7402\\\\Authoring\\\\Help\\\\"}}'
$ py3 "/Applications/Audiokinetic/Wwise 2019.2.9/SDK/samples/WwiseAuthoringAPI/python/low-level/hello-wwise-wamp/main_py3.py"
2021-03-09T17:01:02 failing WebSocket opening handshake ('WebSocket connection upgrade failed (403 - Forbidden)')
2021-03-09T17:01:02 dropping connection to peer tcp4:127.0.0.1:8080 with abort=True: WebSocket connection upgrade failed (403 - Forbidden)
$ python3 "D:\Audiokinetic\Wwise_2019.2.9.7459\SDK\samples\WwiseAuthoringAPI\python\waapi-client-py3\rpc.py"
Getting Wwise instance information:
{'apiVersion': 1,
 'branch': 'wwise_v2019.2',
 'configuration': 'release',
 'copyright': '(C) 2006-2021. Audiokinetic Inc. All rights reserved.',
 'directories': {'authoring': 'D:\\Audiokinetic\\Wwise_2019.2.9.7459\\Authoring\\',
                 'bin': 'D:\\Audiokinetic\\Wwise_2019.2.9.7459\\Authoring\\x64\\Release\\bin\\',
                 'help': 'D:\\Audiokinetic\\Wwise_2019.2.9.7459\\Authoring\\Help\\',
                 'install': 'D:\\Audiokinetic\\Wwise_2019.2.9.7459\\',
                 'log': 'D:\\Audiokinetic\\Wwise_2019.2.9.7459\\Authoring\\x64\\Release\\bin\\Logs\\',
                 'user': 'C:\\Users\\beinanli\\AppData\\Roaming\\Audiokinetic\\Wwise'},
 'displayName': 'Wwise',
 'isCommandLine': False,
 'platform': 'x64',
 'processId': 3468,
 'processPath': 'D:\\Audiokinetic\\Wwise_2019.2.9.7459\\Authoring\\x64\\Release\\bin\\Wwise.exe',
 'version': {'build': 7459,
             'displayName': 'v2019.2.9',
             'major': 2,
             'minor': 9,
             'nickname': '',
             'schema': 97,
             'year': 2019}}
Query the Default Work Unit information:
{'return': [{'id': '{88012962-D6A8-4400-BC86-DF1A5980EDFA}',
             'name': 'Default Work Unit',
             'type': 'WorkUnit'}]}

Questions

Without serious debugging, I cannot rule out the possibility that my office security setup may have influence over WAMP-based ops. But waapi-client does not support HTTP, so I don't have a workaround right now.

I wish that WAMP support could give more diagnostics to help me figure out if it's a bug or simply my setup problem. Also, it would be greatly appreciated if HTTP could work with waapi-client.

ak-slongchamps commented 3 years ago

I cannot seem to repro this issue using macOS Catalina 10.15.7 (19H2) and Python 3.9.2, also with chinese locale, even after purging and reinstalling with a clean cache, so it definitely looks like a network issue. More specifically, WebSocket opening handshake ('WebSocket connection upgrade failed (403 - Forbidden)') looks like an issue with the allowed host. Have you tried adding your hostname and related ips to the Known Host configuration of the Authoring?

image

With regards to HTTP, it's a nice feature request. The limitation of HTTP is its lack of bi-directional communication, which rules out the subscription with event handler part of the system. For that reason, HTTP may be used for quick scripting, but I think WAMP should be preferred for more complicated cases that waapi-client-python intends to support.

A dedicated developer can definitely add the feature without too much problem as the WAMP code is fairly decoupled from the client wrapper through a queue system. One would probably want to implement a variant of _WampClientThread and adapt how the subscription function is made available in the main client class depending on the backend used.

kakyoism commented 3 years ago

Solved. Port 8080 was used by a background process. Sorry for the bother.