Technical Report: HTTP 413 Entity Too Large Error in Stellarium Remote Control / Script Editor /Execution error #5044
Replies: 3 comments 2 replies
|
Hear, hear. The 'direct' API has been designed for rapid execution of 1-5 line scripts that one can assign to a RC GUI button. Longer scripts, those that usually take weeks to develop, usually come as stored files for which 'run' is the API to call for execution. |
|
@gzotti I want to be honest: I cannot guarantee zero performance impact without thorough testing. However, I believe the risk is manageable because:
Bottom line: 500 KB is a fair, conservative limit that solves the immediate problem without introducing unnecessary risk. Users who need more can adjust, but for the vast majority, 500 KB will be more than enough. |
|
Any Idea ? |
Uh oh!
There was an error while loading. Please reload this page.
Comprehensive Analysis and Solutions for Large Script Execution
@gzotti @alex-w @10110111
Report ID: RC-HTTP-413-001
Date: July 18, 2026
Author: kutaibaa-akraa
Related PR: #4956 - Comprehensive Remote Control Enhancement
1. Executive Summary
The Stellarium Remote Control plugin, enhanced with the new Script Editor module, enables users to generate and execute complex Stellarium Script (.ssc) files directly from the web interface. However, when attempting to run scripts larger than approximately 15 KB (e.g., constellation tours with 51+ constellations, star tours with hundreds of entries), the server returns HTTP 413 Entity Too Large.
This report documents the root cause, analyzes the server architecture, and provides two concrete solutions:
config.iniThe issue is critical because it prevents the execution of scripts that are essential for educational presentations, sky culture tours, and automated sequences.
2. Problem Description
2.1 Observed Behavior
When a user writes or generates a script in the Script Editor and clicks "Run" (Ctrl+Enter):
/api/scripts/direct2.2 Scripts That Fail
core.debug("test"))Note: The script file size alone does not determine failure. I think URL encoding adds 1-3% overhead. A 11 KB file becomes ~16,435 bytes after encoding, exceeding the 16,384 byte limit by just 51 bytes.
2.3 Console Output
2.4 Error Propagation
3. Root Cause Analysis
3.1 Where Is the Limit Defined?
The HTTP server used by the Remote Control plugin is QtWebApp. The request size limit is defined in
HttpConnectionHandlerSettings:stellarium/plugins/RemoteControl/src/qtwebapp/httpserver/httpconnectionhandler.h
Line 45 in f8564ac
maxRequestSize= 16,384 bytes (16 KB) – This is the limit for standard POST bodies (includingapplication/x-www-form-urlencoded)maxMultipartSize= 1,048,576 bytes (1 MB) – This is the limit for multipart/form-data uploads3.2 Why 16 KB Was Sufficient Previously
The Remote Control plugin was originally designed for:
/api/main/status, parameter changes)stelsscbuttons (single-line script commands)None of these original use cases required sending more than a few hundred bytes. The Script Editor fundamentally changes this by enabling full script code transmission.
3.3 Why Doesn't
config.iniWork Currently?The Remote Control module does not read
maxRequestSizeormaxMultipartSizefromconfig.ini. Looking atRemoteControl.cpp:stellarium/plugins/RemoteControl/src/RemoteControl.cpp
Line 308 in f8564ac
And in
startServer():stellarium/plugins/RemoteControl/src/RemoteControl.cpp
Line 272 in f8564ac
The
HttpListenerSettingsstruct inherits fromHttpConnectionHandlerSettings, which containsmaxRequestSizeandmaxMultipartSize, but these fields are never populated from configuration.4. Solution 1: Hardcoded Fix (Simple)
4.1 Description
Modify the default values directly in
httpconnectionhandler.h.4.2 Implementation
stellarium/plugins/RemoteControl/src/qtwebapp/httpserver/httpconnectionhandler.h
Line 45 in f8564ac
4.3 Advantages
4.4 Disadvantages
4.5 Recommended Value
maxRequestSizemaxMultipartSizereadTimeout5. Solution 2: Configurable Fix (Recommended)
5.1 Description
Add support for
maxRequestSizeandmaxMultipartSizeinconfig.ini, allowing users to customize the limit without recompilation.5.2 Implementation Details
Step 1: Add Properties to (
RemoteControl.hpp)Step 2: Read Settings in (
RemoteControl.cpp)Step 3: Apply Settings in
startServer()(
RemoteControl.cpp)Step 4: User Configuration
Users can then add to
config.ini:5.3 Advantages
config.iniand restart5.4 Disadvantages
5.5 Recommended Default Values
maxRequestSizemaxMultipartSize6. Recommendation
6.1 Immediate Action (For PR #4956)
Implement Solution 2 (Configurable Fix) as the primary approach.
Provides maximum flexibility for users, Allows different configurations for different use cases
6.2 Testing Recommendations
After implementation, test with:
7. Impact on Related Modules
7.1 Script Editor
7.2 Sky Culture Tour Generator
8. Conclusion
The HTTP 413 Entity Too Large error is a critical blocker for the Script Editor that I intending to test. The default 16 KB limit in QtWebApp is insufficient for scripts that are now being generated by the Sky Culture Tour Generator and other tools.
The solution is straightforward: either increase the default limit (Hardcoded Fix) or add user-configurable support (Configurable Fix). Both are simple to implement and have minimal risk.
The Configurable Fix (Solution 2) is very recommended because it provides the best user experience and future flexibility.
9. References
Related Code Files
httpconnectionhandler.hmaxRequestSize(16 KB default)httpconnectionhandler.cpphttprequest.cppRemoteControl.cppScriptService.cpp/api/scripts/directPOST requestsRelated Issues
All reactions