trompamusic / trompace-client

A python library to read from and write to the Trompa CE
Apache License 2.0
1 stars 0 forks source link

websocket connection error #44

Closed aggelosgkiokas closed 3 years ago

aggelosgkiokas commented 4 years ago

Trying this:

    ws_host = "wss://trompa-mtg.upf.edu/ce/graphql" // this what returned by the trompace.config
    async with websockets.connect(ws_host, subprotocols=['graphql-ws']) as websocket:
        print("Do something")

I get the following error:

File "/home/aggelos/envs/tpl/lib/python3.7/site-packages/websockets/client.py", line 517, in __aenter__ return await self File "/home/aggelos/envs/tpl/lib/python3.7/site-packages/websockets/client.py", line 547, in __await_impl__ extra_headers=protocol.extra_headers, File "/home/aggelos/envs/tpl/lib/python3.7/site-packages/websockets/client.py", line 296, in handshake raise InvalidStatusCode(status_code) websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 400 python-BaseException

Probably is related to secure connection

alastair commented 4 years ago

I'll take a look into this, but first of all try with ws://, because this connection isn't secure. See if that works

aggelosgkiokas commented 4 years ago

No it doesn't. I get a invalid URI message.

File "/home/aggelos/envs/tpl/lib/python3.7/site-packages/websockets/client.py", line 517, in aenter return await self File "/home/aggelos/envs/tpl/lib/python3.7/site-packages/websockets/client.py", line 557, in __await_impl__ self.handle_redirect(exc.uri) File "/home/aggelos/envs/tpl/lib/python3.7/site-packages/websockets/client.py", line 483, in handle_redirect new_wsuri = parse_uri(uri) File "/home/aggelos/envs/tpl/lib/python3.7/site-packages/websockets/uri.py", line 66, in parse_uri raise InvalidURI(uri) from exc websockets.exceptions.InvalidURI: https://trompa-mtg.upf.edu/ce/graphql isn't a valid URI python-BaseException

Process finished with exit code 1

Is it possible to have a non-secure wensocket connection over a secure server??? In any case the config.py https://github.com/trompamusic/trompa-ce-client/blob/2fcad51a59d0337f2d824ee24a64acf42c0666fb/trompace/config.py#L58 should be updated in the set_server() function to return the correct URI.

alastair commented 3 years ago

Was invalid configuration in trompa-mtg nginx configuration