reportportal / client-javascript

This Client is to communicate with the ReportPortal on Node.js.
https://www.npmjs.com/package/@reportportal/client-javascript
Apache License 2.0
16 stars 51 forks source link

allow using custom client config in checkConnection() method #206

Closed stevez closed 3 months ago

stevez commented 3 months ago

I found the client will throw error of "400 BAD request" when running behind the proxy. based on this article: https://stackoverflow.com/questions/60578209/axios-proxy-configuration-causing-bad-request In order to make the client working behind the proxy, I found I need to add some custom parameters in the RPClient,

const { HttpsProxyAgent } = require('https-proxy-agent');

const agent = new HttpsProxyAgent('http://proxy_url:port');

const rpClient = new RPClient({
    apiKey: 'reportportalApiKey',
    endpoint: 'http://your-instance.com:8080/api/v1',
    launch: 'LAUNCH_NAME',
    project: 'PROJECT_NAME',
    restClientConfig: {
          proxy: false,
          httpsAgent: proxy,
    }
});

I found the solution will work in the startLaunch() method, but not checkConnection(), then I need to realize we need to pass the restClientConfig object to checkConnection() as well, after this fix, then we can use the client work under the corporate proxy using the above code snippet.

AmsterGet commented 3 months ago

Just curious: did you get error code 400 on all requests using the default proxy configuration that axios comes with?

AmsterGet commented 3 months ago

Associated with https://github.com/reportportal/client-javascript/pull/205

stevez commented 3 months ago

Just curious: did you get error code 400 on all requests using the default proxy configuration that axios comes with?

Yes, I tried to use the playwright example to publish to the demo site, I saw all the requests have issues; but in my local server, I only see the first one has the 400 error

AmsterGet commented 3 months ago

Hi @stevez ! I would like to include the use of HttpsProxyAgent in this package to allow users to specify proxy settings in the same way as for the http proxies that axios supports. This would also be useful for our agents that already use this client and provide it with a configuration that can be deserialized from a string.

Could you take a look and test it for your use case if possible? https://github.com/reportportal/client-javascript/pull/205

Thank you in advance!

stevez commented 2 months ago

Yes I will look at today, sorry for the delay response

stevez commented 2 months ago

Check my comment in you pr