400 Bad Request with proxy configuration
Hi ! I have a problem when using this SDK with a proxy configuration. Datadog requests don't reach at all the proxy.
When events are send, I've got this error on XCode (I don't have any errors on JS side) :
nw_http_connect_process_response [C12.1.1.1:3] http connect Proxy received status: HTTP/1.1 400 Bad Request
What I don't understand is that the requests are send very well with plain local server, I have this :
nw_http_connect_process_response [C21.1.1:3] http connect Proxy received status: HTTP/1.0 501 Unsupported method ('CONNECT')
I can the see the requests in my local server.
This is the configuration that I'm using for testing
datadogConfiguration.proxyConfig = new ProxyConfiguration(ProxyType.HTTPS, '0.0.0.0', 443)
- Version of the SDK: 1.8.5
- Version of React Native: 0.71.6
Thanks for the help !
After some investigation, it seems that my proxy server doesn't handle the CONNECT method, causing this error. I'll do the necessary in the proxy
Is it possible to tell to the SDK to not using CONNECT method, and only GET/POST methods ?
Hi @martinezguillaume, we currently use the native iOS URLSession and Android okhttp proxy functionalities that rely on CONNECT to forward the requests.
If you're interested in us adding GET/POST methods, I recommend you to reach out to our support team so we can better prioritize this feature :)
Let me know if you need help on anything else!
Hi there,
What is the ProxyType used for? It seems that selecting HTTPS or HTTP both ends up in creating a tunnel using HTTP CONNECT method (no difference).
Is there a configuration that will not use CONNECT, resulting in something similar as using browser RUM proxy configuration ?
Hi @fguffon,
As mentioned in this similar issue, we're planning to add soon a customEndpoint parameter for each feature (RUM, Logs, Trace) that would enable you to achieve something similar to what the browser proxy is doing.
In the current state of the SDK there is no such feature, the proxy configuration will always use CONNECT requests.
Indeed the ProxyType HTTPS and HTTP have the same behaviour today. I think it was intended to have a different behaviour on iOS, and the HTTPS type should not create an http tunnel. We'll make that change as well in the same effort.
I hope that answers your questions, let me know if I can help further!
Hi @martinezguillaume @fguffon!
We released a customEndpoints configuration option in 2.1.0 version of the SDK.
It enables you to specify an endpoint for data to be sent to. For instance if you specify in your configuration:
config.customEndpoints = {
rum: 'https://my-custom-endpoint.com',
logs: 'https://my-custom-endpoint.com',
trace: 'https://my-custom-endpoint.com',
}
Your RUM data will be sent to https://my-custom-endpoint.com/api/v2/rum, your logs data to /api/v2/logs and your trace data to /api/v2/spans.
One important note is that this is not an official alternative to the proxy configuration yet - making it so requires more time and we have more pressing items in our backlog. So if you decide to use it for this purpose keep in mind that:
- Although it should work well, we haven't tested all scenarios extensively. Feel free to open an issue or a PR if you notice some data isn't reported as expected.
- As this isn't officially documented the path we send your data to might change in the future. If so, it would be mentioned in the release notes.
Let me know if this fixes your use case!
hi @louiszawadzki Thanks it's perfectly doing the job for us. The only feedback I have is that comparing to the configuration used on web RUM proxy configuration, there is a discrepancy retrieving the full path (/api/v2/rum) that is added in the ddforward parameter, but for now the change allowed us to make it work !