Json web/RPC port arg#134
Open
mitchcapper wants to merge 2 commits into
Open
Conversation
throwaway96
reviewed
Jun 1, 2026
| ERR("Error! Connection timeout."); | ||
| res = hyperion_read(); | ||
| if (res < 0) { | ||
| ERR("Error! Connection timeout our error code: %d errno: %s", res, strerror(errno)); |
Author
There was a problem hiding this comment.
No. As I modified hyperion_read to return several different error codes rather than just one I was stating that our internal error code is X and the last system error was Y.
There was a problem hiding this comment.
Pull request overview
Adds configurability for the Hyperion JSON-RPC/web port (default 8090) and expands diagnostics around read failures, so the service can target non-default RPC setups while providing more actionable error information.
Changes:
- Introduce
web_portin settings, initialize it to 8090, and (de)serialize it to/from JSON config. - Add
--web-portCLI option and use the configured port when callingset_hdr_state(...). - Refine
hyperion_read()return codes and update connection-loop logging.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| src/settings.h | Adds web_port to the settings struct. |
| src/settings.c | Initializes web_port, loads it from JSON, and saves it to JSON. |
| src/main.c | Adds --web-port CLI flag and wiring to settings. |
| src/service.c | Uses settings->web_port instead of a fixed RPC port; improves read-error logging. |
| src/json_rpc_client.h | Removes the fixed RPC_PORT define (port now configured elsewhere). |
| src/hyperion_client.c | Adds distinct negative return codes for different read failures. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
98
to
101
| jobject_set(target, j_cstr_to_buffer("address"), jstring_create(settings->address)); | ||
| jobject_set(target, j_cstr_to_buffer("port"), jnumber_create_i32(settings->port)); | ||
| jobject_set(target, j_cstr_to_buffer("web_port"), jnumber_create_i32(settings->web_port)); | ||
| jobject_set(target, j_cstr_to_buffer("priority"), jnumber_create_i32(settings->priority)); |
Comment on lines
+58
to
+59
| if ((value = jobject_get(source, j_cstr_to_buffer("web-port"))) && jis_number(value)) | ||
| jnumber_get_i32(value, &settings->web_port); |
Comment on lines
9
to
12
| settings->address = strdup(""); | ||
| settings->port = 19400; | ||
| settings->web_port = 8090; | ||
| settings->priority = 150; |
Comment on lines
14
to
17
| char* address; | ||
| int port; | ||
| int web_port; | ||
| int priority; |
Comment on lines
29
to
33
| { "height", required_argument, 0, 'y' }, | ||
| { "address", required_argument, 0, 'a' }, | ||
| { "port", required_argument, 0, 'p' }, | ||
| { "web-port", required_argument, 0, 'w' }, | ||
| { "unix-socket", no_argument, 0, 'l' }, |
Comment on lines
61
to
64
| printf(" -a, --address=ADDR IP address of Hyperion server\n"); | ||
| printf(" -p, --port=PORT Port of Hyperion flatbuffers server (default 19400)\n"); | ||
| printf(" -w, --web-port=PORT Port of Hyperion RPC/web server (default 8090)\n"); | ||
| printf(" -l, --unix-socket Connect through unix socket\n"); |
Comment on lines
86
to
90
| int ret; | ||
|
|
||
| while ((opt = getopt_long(argc, argv, "x:y:a:p:f:b:u:q:c:lvnhdVGrst", long_options, &longindex)) != -1) { | ||
| while ((opt = getopt_long(argc, argv, "x:y:a:p:w:f:b:u:q:c:lvnhdVGrst", long_options, &longindex)) != -1) { | ||
| switch (opt) { | ||
| case 'x': |
Comment on lines
+103
to
+105
| case 'w': | ||
| settings.web_port = atol(optarg); | ||
| break; |
Comment on lines
51
to
+55
| int n = read(sockfd, headbuff, 4); | ||
| uint32_t messageSize = ((headbuff[0] << 24) & 0xFF000000) | ((headbuff[1] << 16) & 0x00FF0000) | ((headbuff[2] << 8) & 0x0000FF00) | ((headbuff[3]) & 0x000000FF); | ||
| if (n < 0 || messageSize >= sizeof(recvBuff)) | ||
| return -1; | ||
| if (n < 0) | ||
| return -3; | ||
| if (messageSize >= sizeof(recvBuff)) |
Comment on lines
+40
to
44
| res = hyperion_read(); | ||
| if (res < 0) { | ||
| ERR("Error! Connection timeout our error code: %d errno: %s", res, strerror(errno)); | ||
| break; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add option to specify the RPC port if it is not 8090.
Also minor logging improvements for read errors.