zisco Posted July 22 Share Posted July 22 I get this ssl_cli.c:2297 0x3ffe40a4 server did not confirm our fragment length request, disabling message when calling this - any ideas how to pass options (like disable_fragmentation: true) to Shelly.call?? function ElectricityCost() { let url = CONFIG.electricityCostForecastEndpoint; console.log(url); Shelly.call( "http.get", { url: CONFIG.electricityCostForecastEndpoint }, function (response, error_code, error_message) { let electricityData = JSON.parse(response.body); } ); } Quote Link to comment Share on other sites More sharing options...
johann.pascher Posted August 26 Share Posted August 26 When calling HTTP requests in Shelly scripts using `Shelly.call`, passing options such as `disable_fragmentation` is not directly supported in the same way as it might be with some other HTTP libraries. Instead, you should focus on correctly formatting your request and handling the responses. Here’s how you can make HTTP requests and manage response fragmentation issues in Shelly scripts: ### Example Function with HTTP GET Request If you want to use `Shelly.call` to make an HTTP GET request, here's a refined version of your function: function ElectricityCost() { let url = CONFIG.electricityCostForecastEndpoint; console.log(url); Shelly.call( "http.get", { url: url }, function (response, error_code, error_message) { if (error_code !== 0) { console.error(`Error code: ${error_code}, Message: ${error_message}`); return; } try { let electricityData = JSON.parse(response.body); console.log(electricityData); // Process the electricityData as needed } catch (e) { console.error("Failed to parse response body:", e); } } ); } ### Key Points 1. **Handling Response Fragmentation**: The `disable_fragmentation` option is typically used to handle large responses in chunks, but Shelly’s HTTP handling API might not directly support this. Ensure your endpoint returns manageable-sized responses to avoid issues with fragmentation. 2. **Error Handling**: Check the `error_code` and `error_message` returned in the callback to handle errors properly. This helps in diagnosing any issues with the HTTP request. 3. **Parsing Responses**: Use `try...catch` when parsing JSON to handle any unexpected format issues gracefully. 4. **Configuration**: Ensure that `CONFIG.electricityCostForecastEndpoint` is correctly defined and accessible. 5. **Shelly API Documentation**: Always refer to the Shelly API documentation or community forums for any device-specific nuances or updates regarding HTTP request handling. If you need more specific behavior or encounter issues with large responses, you might need to handle data in smaller chunks or adjust your server-side implementation to accommodate the limitations of the Shelly HTTP API. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.