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

Any hints on how to use the TCP API? #73

Open
RudolfVonKrugstein opened this issue Dec 26, 2024 · 2 comments
Open

Any hints on how to use the TCP API? #73

RudolfVonKrugstein opened this issue Dec 26, 2024 · 2 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@RudolfVonKrugstein
Copy link

Hi,

The TCP API seems to be not documented (yet). Any hints, or simple example on how to use it? I would like to use onnxruntimer-server for serving silero VAD and using it via TCP api.

Thanks you!

@kibae
Copy link
Owner

kibae commented Dec 27, 2024

Hi, @RudolfVonKrugstein

You're right, there's no documentation for the TCP API yet. I created it to work with the pg_onnx project, I didn't think anyone would use it.
I'll try to explain it briefly and write some documentation after my vacation.

struct protocol_header {
int16_t type;
int64_t length;
int64_t json_length;
int64_t post_length;
} __attribute__((packed));

The structure of the protocol headers. The header contains the kind of operation you are requesting, the length of the entire request (JSON+POST), the length of the JSON data, and the length of the POST data (non-JSON data).
The types of operations are defined here.
enum type : int16_t {
CREATE_SESSION = 1,
EXECUTE_SESSION = 5,
DESTROY_SESSION = 9,
LIST_SESSION = 21,
GET_SESSION = 22,
};

After the header, you can send JSON data and after that POST data. Attach some of the E2E test code.

auto json_data = json.dump();
struct onnxruntime_server::transport::tcp::protocol_header header = {};
header.type = htons(type);
header.length = HTONLL(json_data.size() + post_size);
header.json_length = HTONLL(json_data.size());
header.post_length = HTONLL(post_size);
std::vector<boost::asio::const_buffer> buffers;
buffers.emplace_back(&header, sizeof(header));
buffers.emplace_back(json_data.c_str(), json_data.size());
if (post != nullptr)
buffers.emplace_back(post, post_size);

Have a great holiday season! 🥳

@RudolfVonKrugstein
Copy link
Author

Thank you! I will try it after the holidays. And I will leave the issue open for you to decide if you want to close it now or when there is documentation.

@kibae kibae added the documentation Improvements or additions to documentation label Dec 31, 2024
@kibae kibae self-assigned this Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants