<!-- Kamailio Project uses GitHub Issues only for bugs in the code or feature requests. Please use this template only for feature requests.
If you have questions about using Kamailio or related to its configuration file, ask on sr-users mailing list:
* http://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
If you have questions about developing extensions to Kamailio or its existing C code, ask on sr-dev mailing list:
* http://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev
Please try to fill this template as much as possible for any issue. It helps the developers to troubleshoot the issue.
If you submit a feature request (or enhancement) add the description of what you would like to be added.
If there is no content to be filled in a section, the entire section can be removed.
You can delete the comments from the template sections when filling.
You can delete next line and everything above before submitting (it is a comment). -->
### Description Could a module parameter be added to retry a request _n_ number of times in the event of a connection or server failure, without having to write a tedious bit of boiler plate config to catch failure response codes and retry.
### Expected behavior A http(s) post or get is performed and the returned code is < 0 but > -20 (null url return code in libruxc) or is a 5xx or 6xx http error code. The module will reattempt the request up to the number of attempts defined in a module parameter. By default this behaviour is disabled and would require explicitly defining the module parameter to enable it. Requests could be exempted from automatic retries by either adding an additional argument to the function called in config, or a http header could be supplied `X-RUXC-NORETRY` for example using the existing function signature to exclude the request. The header name could also be defined as a module parameter.
Closed #2820.
Thanks for the idea!
This feature is also probably suitable to be implemented in the libruxc, to avoid passing data back and forth many times, rather than using the libruxc as it is now and do the retry in Kamailio module C code.
Then kamailio can get a modparam (and/or other options) to control it.
I added to my todo for libruxc, if you want to discuss more, let's do it with an issue for ruxc project (https://github.com/miconda/ruxc).
Just had a bash at adding this myself, and it seems to work nicely for my usecase... Adding this changing calls to post or get, and defining a parameter for retry attempts ``` ruxc_http_get(&v_http_request, &v_http_response); //Retry enabled, either have a server error code or a connection error int attempt; attempt = 0; while(attempt < _ruxc_http_retry && (v_http_response.retcode < 0 || (v_http_response.rescode > 499 && v_http_response.rescode < 699)){ attempt++; LM_DBG("Retrying Request Attempt: %d - Response Code: %d - Return Code: %d - URI: %s\n", attempt, v_http_response.retcode, v_http_response.rescode, v_http_request.url); ruxc_http_get(&v_http_request, &v_http_response); } ``` Im loving ruxc lol
@nakchak - this is in the kamailio module, isn't better to add a new field in the v_http_request structure and do the retry in libruxc? I saves time for http agent creation or lookup (on reuse).
@miconda Agreed, have opened an issue in the ruxc repo, was more of an interim fix, but i think it makes absolute sense to have it at lib level