Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to connect to Kuksa databroker server #33

Open
TheLittleNaruto opened this issue Jun 16, 2024 · 5 comments
Open

Unable to connect to Kuksa databroker server #33

TheLittleNaruto opened this issue Jun 16, 2024 · 5 comments

Comments

@TheLittleNaruto
Copy link

Hi

I am trying Kuksa python SDK to connect to kuksa databroker. However it fails to connect.

Steps which I followed:

To start the databroker server:

tln@tln-X550LD:~/Kuksa$ sudo docker run -it --rm --name Server --network kuksa ghcr.io/eclipse-kuksa/kuksa-databroker:main --insecure
[sudo] password for tln: 
2024-06-16T12:35:01.443571Z  INFO databroker: Init logging from RUST_LOG (environment variable not found)
2024-06-16T12:35:01.443589Z  INFO databroker: Starting Kuksa Databroker 0.4.6
2024-06-16T12:35:01.444322Z  INFO databroker: Populating metadata from file 'vss_release_4.0.json'
2024-06-16T12:35:01.726938Z  WARN databroker: Authorization is not enabled.
2024-06-16T12:35:01.727027Z  INFO databroker::broker: Starting housekeeping task
2024-06-16T12:35:01.727055Z  INFO databroker::grpc::server: Listening on 0.0.0.0:55555
2024-06-16T12:35:01.727065Z  INFO databroker::grpc::server: TLS is not enabled
2024-06-16T12:35:01.727073Z  INFO databroker::grpc::server: Authorization is not enabled.

To verify the connect, ran the databroker-cli

tln@tln-X550LD:~/Kuksa$ sudo docker run -it --rm --network kuksa ghcr.io/eclipse-kuksa/kuksa-databroker-cli:main --server Server:55555
Using kuksa.val.v1

  ⠀⠀⠀⢀⣤⣶⣾⣿⢸⣿⣿⣷⣶⣤⡀
  ⠀⠀⣴⣿⡿⠋⣿⣿⠀⠀⠀⠈⠙⢿⣿⣦⠀
  ⠀⣾⣿⠋⠀⠀⣿⣿⠀⠀⣶⣿⠀⠀⠙⣿⣷   
  ⣸⣿⠇⠀⠀⠀⣿⣿⠠⣾⡿⠃⠀⠀⠀⠸⣿⣇⠀⠀⣶⠀⣠⡶⠂⠀⣶⠀⠀⢰⡆⠀⢰⡆⢀⣴⠖⠀⢠⡶⠶⠶⡦⠀⠀⠀⣰⣶⡀
  ⣿⣿⠀⠀⠀⠀⠿⢿⣷⣦⡀⠀⠀⠀⠀⠀⣿⣿⠀⠀⣿⢾⣏⠀⠀⠀⣿⠀⠀⢸⡇⠀⢸⡷⣿⡁⠀⠀⠘⠷⠶⠶⣦⠀⠀⢠⡟⠘⣷
  ⢹⣿⡆⠀⠀⠀⣿⣶⠈⢻⣿⡆⠀⠀⠀⢰⣿⡏⠀⠀⠿⠀⠙⠷⠄⠀⠙⠷⠶⠟⠁⠀⠸⠇⠈⠻⠦⠀⠐⠷⠶⠶⠟⠀⠠⠿⠁⠀⠹⠧
  ⠀⢿⣿⣄⠀⠀⣿⣿⠀⠀⠿⣿⠀⠀⣠⣿⡿
  ⠀⠀⠻⣿⣷⡄⣿⣿⠀⠀⠀⢀⣠⣾⣿⠟    databroker-cli                
  ⠀⠀⠀⠈⠛⠇⢿⣿⣿⣿⣿⡿⠿⠛⠁     v0.4.6                        

Successfully connected to http://Server:55555/
kuksa.val.v1 > publish Vehicle.Speed 42
[publish]  OK  
kuksa.val.v1 > get Vehicle.Speed
[get]  OK  
Vehicle.Speed: 42.00 km/h
kuksa.val.v1 > 

As we can see, it is able to publish to the databroker and get it back.

Now used kuksa python sdk to achieve the same:

tln@tln-X550LD:~/Kuksa/trying-kuksa-python-sdk$ python3 -m venv env
tln@tln-X550LD:~/Kuksa/trying-kuksa-python-sdk$ source env/bin/activate
(env) tln@tln-X550LD:~/Kuksa/trying-kuksa-python-sdk$ pip install kuksa-client

Now ran the kuksa-client command

(env) tln@tln-X550LD:~/Kuksa/trying-kuksa-python-sdk$ kuksa-client

But this resulted in below error:


     ⢀⣤⣶⣾⣿⢸⣿⣿⣷⣶⣤⡀
    ⣴⣿⡿⠋⣿⣿   ⠈⠙⢿⣿⣦
   ⣾⣿⠋  ⣿⣿  ⣶⣿  ⠙⣿⣷
  ⣸⣿⠇   ⣿⣿⠠⣾⡿⠃   ⠸⣿⣇  ⣶ ⣠⡶⠂ ⣶  ⢰⡆ ⢰⡆⢀⣴⠖ ⢠⡶⠶⠶⡦   ⣰⣶⡀
  ⣿⣿    ⠿⢿⣷⣦⡀     ⣿⣿  ⣿⢾⣏   ⣿  ⢸⡇ ⢸⡷⣿⡁  ⠘⠷⠶⠶⣦  ⢠⡟⠘⣷
  ⢹⣿⡆   ⣿⣶⠈⢻⣿⡆   ⢰⣿⡏  ⠿ ⠙⠷⠄ ⠙⠷⠶⠟⠁ ⠸⠇⠈⠻⠦ ⠐⠷⠶⠶⠟ ⠠⠿⠁ ⠹⠧
   ⢿⣿⣄  ⣿⣿  ⠿⣿  ⣠⣿⡿
    ⠻⣿⣷⡄⣿⣿   ⢀⣠⣾⣿⠟    kuksa-client CLI
     ⠈⠛⠇⢿⣿⣿⣿⣿⡿⠿⠛⠁     0.4.3


Connecting to VSS server at 127.0.0.1 port 55555 using KUKSA GRPC protocol.
TLS will not be used.
2024-06-16 17:59:41,321 INFO kuksa_client.grpc: No Root CA present, it will not be possible to use a secure connection!
2024-06-16 17:59:41,321 INFO kuksa_client.grpc.aio: Establishing insecure channel
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/home/tln/Kuksa/trying-kuksa-python-sdk/env/lib/python3.11/site-packages/kuksa_client/grpc/aio.py", line 386, in get_server_info
    resp = await self.client_stub.GetServerInfo(req, **rpc_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tln/Kuksa/trying-kuksa-python-sdk/env/lib/python3.11/site-packages/grpc/aio/_call.py", line 318, in __await__
    raise _create_rpc_error(
grpc.aio._call.AioRpcError: <AioRpcError of RPC that terminated with:
	status = StatusCode.UNAVAILABLE
	details = "failed to connect to all addresses; last error: UNKNOWN: ipv4:127.0.0.1:55555: Failed to connect to remote host: Connection refused"
	debug_error_string = "UNKNOWN:Error received from peer  {created_time:"2024-06-16T17:59:41.323376945+05:30", grpc_status:14, grpc_message:"failed to connect to all addresses; last error: UNKNOWN: ipv4:127.0.0.1:55555: Failed to connect to remote host: Connection refused"}"
>

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/lib/python3.11/threading.py", line 1045, in _bootstrap_inner
    self.run()
  File "/home/tln/Kuksa/trying-kuksa-python-sdk/env/lib/python3.11/site-packages/kuksa_client/__init__.py", line 118, in run
    self.loop.run_until_complete(self.backend.mainLoop())
  File "/usr/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/home/tln/Kuksa/trying-kuksa-python-sdk/env/lib/python3.11/site-packages/kuksa_client/cli_backend/grpc.py", line 276, in mainLoop
    async with kuksa_client.grpc.aio.VSSClient(self.serverIP, self.serverPort, token=self.token) as vss_client:
  File "/home/tln/Kuksa/trying-kuksa-python-sdk/env/lib/python3.11/site-packages/kuksa_client/grpc/aio.py", line 61, in __aenter__
    await self.connect()
  File "/home/tln/Kuksa/trying-kuksa-python-sdk/env/lib/python3.11/site-packages/kuksa_client/grpc/aio.py", line 87, in connect
    logger.debug("Connected to server: %s", await self.get_server_info())
                                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tln/Kuksa/trying-kuksa-python-sdk/env/lib/python3.11/site-packages/kuksa_client/grpc/aio.py", line 102, in wrapper
    return await func(self, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/tln/Kuksa/trying-kuksa-python-sdk/env/lib/python3.11/site-packages/kuksa_client/grpc/aio.py", line 393, in get_server_info
    raise VSSClientError.from_grpc_error(exc) from exc
kuksa_client.grpc.VSSClientError: ({'code': 14, 'reason': 'unavailable', 'message': 'failed to connect to all addresses; last error: UNKNOWN: ipv4:127.0.0.1:55555: Failed to connect to remote host: Connection refused'}, [])
Error: Websocket could not be connected or the gRPC channel could not be created.
2024-06-16 17:59:47,321 INFO kuksa_client.cli_backend.grpc: gRPC channel disconnected.

Could you please help what went wrong here? BTW I also tried to manually connect to databroker, by running below command:

Test Client> connect http://Server:55555
Invalid server URI. Unsupported protocol: http

And it did not work, but same command works on Kuksa databroker-cli.

@wba2hi
Copy link
Contributor

wba2hi commented Jun 18, 2024

Can you try again to connect using kuksa-client grpc://Server:55555 (instead of http://Server:55555)?

Kuksa-Client supports two different protocols, where each uses a custom URI format. On one hand the protocol grpc:// to establish a connection using gRPC and on the other hand ws:// to establish a connection using Websockets. In case TLS is being used it is grpcs://...and wss://

@TheLittleNaruto
Copy link
Author

Can you try again to connect using kuksa-client grpc://Server:55555 (instead of http://Server:55555)?

Kuksa-Client supports two different protocols, where each uses a custom URI format. On one hand the protocol grpc:// to establish a connection using gRPC and on the other hand ws:// to establish a connection using Websockets. In case TLS is being used it is grpcs://...and wss://

I tried both of them, but same error. @wba2hi

@SebastianSchildt
Copy link
Contributor

Can you double check, whether the error is the same, because the original error message said, it does not recognize http, so if you replacaed that with e.g. grpc:// I would at least expect a different error

@SebastianSchildt
Copy link
Contributor

Also you used a docker network "kuksa", are you sure this is reachable from "outside" (because you use venv directly on host for client). I think at least under Linux this may require some routing being set up.

A simple way to test is, instead of using a custom network, use host mode in docker, i.e. start

sudo docker run -it --rm --name Server --net=host ghcr.io/eclipse-kuksa/kuksa-databroker:main --insecure

And then try connecting wiht kuksa-client again (using the IP or hostname of your computer)

@thu4n
Copy link

thu4n commented Sep 12, 2024

I actually had the same error with StatusCode.UNAVAILABLE when using the SDK. I managed to fix this by downgrading the Kuksa Databroker version to 0.4.4 instead of the latest version.

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

No branches or pull requests

4 participants