how to start using kx kdbsolace c++ library with Solace C API Client

ori
ori Member Posts: 4

Hi all
I have integrated Kx Developer + KDb+ + kdbsolace dll on windows with visual studio 14 2015 x64 over VS2017 IDE.

Now I try to send message and lean what happen on the kdb database.

the q kx developer is running
C:\workKXdb\kdb\w64>q
KDB+ 4.0 2021.07.12 Copyright (C) 1993-2021 Kx Systems
w64/ 16(16)core 16160MB ....

q)DEVELOPER_HOME setenv "C:\\workKXdb\\developer" q)DEVELOPER_DATA setenv "C:\workKXdb\developer\data"
q)\p localhost:8080
q)\l C:\workKXdb\developer\launcher.q_
[developer] version 1.5.1
[developer] loading...
[developer] port already set, not changing
[developer] successfully loaded
[developer] connect to: http://desktop-5s9po4j:8080/ax or http://localhost:8080/ax with your web browser

and I can see solace functions on the developer web console...

now I compiled the client and I try to connect one of the solace C API introduction helloworld / pub-sub exectutables examples to pass messages to the database.

it fail to connect with error
C:\workKXdb\solace\solclient-7.20.0.6\Intro\vs2015\bin\Win64\Release>HelloWorldSub.exe 127.0.0.1:55555 default ori Hellow
HelloWorldSub initializing...
SDK NOTICE Mon Dec 6 17:10:33.155 2021 solClient.c:10681 (00000fc8) Session '(c0,s1)_default' error attempting transport connection, client name 'DESKTOP-5S9PO4J/1740/00000001/lXW-KKcjQb', VPN name 'default', peer host '127.0.0.1:55555' address 'IP 127.0.0.1', connection 'tcp_TxRx' local address 'IP 0.0.0.0:18408'
SDK NOTICE Mon Dec 6 17:10:33.161 2021 solClient.c:10209 (00000fc8) Protocol or communication error when attempting to login for session '(c0,s1)_default'; are session HOST and PORT correct? client name 'DESKTOP-5S9PO4J/1740/00000001/lXW-KKcjQb', VPN name 'default', peer host '127.0.0.1:55555' address 'IP 127.0.0.1', connection 'tcp_TxRx' local address 'IP 0.0.0.0:18408'
Connected.
SDK NOTICE Mon Dec 6 17:10:33.166 2021 solClientSubscription.c:5809 (00003228) Attempt to call solClient_session_topicSubscribeExt when session '(c0,s1)_default' not established
Waiting for message......

the publisher executes and terminate without an error

C:\workKXdb\solace\solclient-7.20.0.6\Intro\vs2015\bin\Win64\Release>HelloWorldPub.exe 127.0.0.1:55555 default ori "Hellow World"
HelloWorldPub initializing...
SDK NOTICE Mon Dec 6 17:08:15.597 2021 solClient.c:10681 (00000d90) Session '(c0,s1)_default' error attempting transport connection, client name 'DESKTOP-5S9PO4J/10284/00000001/XRbgupK6vw', VPN name 'default', peer host '127.0.0.1:55555' address 'IP 127.0.0.1', connection 'tcp_TxRx' local address 'IP 0.0.0.0:12520'
SDK NOTICE Mon Dec 6 17:08:15.605 2021 solClient.c:10209 (00000d90) Protocol or communication error when attempting to login for session '(c0,s1)_default'; are session HOST and PORT correct? client name 'DESKTOP-5S9PO4J/10284/00000001/XRbgupK6vw', VPN name 'default', peer host '127.0.0.1:55555' address 'IP 127.0.0.1', connection 'tcp_TxRx' local address 'IP 0.0.0.0:12520'
Connected.
About to send message 'Hello world!' to topic 'Hellow World'...
Message sent. Exiting.

C:\workKXdb\solace\solclient-7.20.0.6\Intro\vs2015\bin\Win64\Release>

can you help me create the connection and fix the "session '(c0,s1)_default' not established" error?

Thanks for advance
Ori

Best Answer

  • himanshu
    himanshu Member, Employee Posts: 67 Solace Employee
    edited December 2021 #2 Answer ✓

    We had a call with @ori and it seems like the docker config file was mapping port 55555 to 55554. Changing the port number fixed the issue.

Answers

  • ivan_lkc
    ivan_lkc Member Posts: 11 ✭✭

    Looking at the publisher logs carefully reveals it also suffer the same error: "Protocol or communication error when attempting to login". Both the publisher and subscriber are not able to establish a connection to 127.0.0.1:55555. Are you sure you have a working Solace Broker running in your local computer at port 55555? That Broker highly likely needs to be a third process.

  • ori
    ori Member Posts: 4
    edited December 2021 #4

    Thanks Ivan for the fast response
    I am new to KX , KDb+ and Solace. I have experience with messaging over tcp and http and know the concepts, will need deeper reference to integration of the broker.
    Currently the system has the following components:
    1. KX Developer web IDE, verified it's operating
    2. KX KDb+ q console , verified it's operating
    3. libsolclient.dll link to file. win64 bit vc v140 VS2015 . downloaded solclient-7.20.0.6
    4. solacekdb.dll win64 bit vc v140 VS2015 target on vs2017 IDE built it myself, and solace.q q script
    (C:\workKXdb\solace\solace_build>cmake -G "Visual Studio 14 2015 Win64" --config Release ../solace)

    following tutorial shows solacekdb is the broker, how should one launch this broker to allow the pub-sub operation?

    if there is reference code of solclient project solClientOS.c , solClientSession.c or debug version with stack trace code debugging with visual studio I can try gather more details on the connection parameters flow threw the code....

    Thanks for advnce
    Ori Kovacsi Katz

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 538 admin

    Hey @ori, following on what @ivan_lkc mentioned, it seems like you dont have a solace broker running locally on your machine. To use Solace PubSub+ Broker you have 3 options
    1. Software
    2. Cloud
    3. Hardware

    The first two options are the most accessible. Note, if you decide to spin up a cloud broker service (which is free btw with a trial period!), you will have to change the connection parameters instead of using your local host 127.0.0.1:55555

    We also have tutorials on using the Solace C API https://tutorials.solace.dev/c/publish-subscribe/

  • ori
    ori Member Posts: 4

    Thanks Tamimi

    I need step by step instructions to install / integrate "Solace PubSub+ Broker" with option 1. Software. I am a software developer and need long term available KDb+ + SolaceKdb + Client.

    Only once I have functional server software I will start working on concurrency and deployment scalability on cloud / fpga

    Is there a simple tutorial how to install and integrate the broker?

    B.R.
    Ori

  • Tamimi
    Tamimi Member, Administrator, Employee Posts: 538 admin

    For sure!

    Check out these steps here to show you how to install and configure your Docker solace broker https://solace.com/products/event-broker/software/getting-started/

    Note that there are other flavours of the broker for software installation if you dont want to use docker (for example you want to use virtual images instead) and you can find further details and instructions about it here in the docs https://docs.solace.com/Solace-SW-Broker-Set-Up/Release-Packages.htm

    Hopefully this helps!

  • himanshu
    himanshu Member, Employee Posts: 67 Solace Employee
    edited December 2021 #8 Answer ✓

    We had a call with @ori and it seems like the docker config file was mapping port 55555 to 55554. Changing the port number fixed the issue.

  • hong
    hong Guest Posts: 480 ✭✭✭✭✭

    Thanks, @himanshu! @ori, can you accept Himanshu's as the best answer?

  • ori
    ori Member Posts: 4

    @himanshu said:
    We had a call with @ori and it seems like the docker config file was mapping port 55555 to 55554. Changing the port number fixed the issue.

    I would like to add my "50 cents" to the answer for new developers, this setup is the default setup of the "standard" "Software" flavour docker instance. it is on PubSubStandard_singleNode.yml docker configuration file.
    as appears with SMF section

          #SMF
          - '55554:55555'