Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Conversation

stevez
Copy link
Contributor

@stevez stevez commented Jun 17, 2024

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.

Copy link
Member

@AmsterGet AmsterGet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stevez Thanks for the contribution!

@AmsterGet
Copy link
Member

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

@AmsterGet
Copy link
Member

Associated with #205

@AmsterGet AmsterGet merged commit 679c72c into reportportal:develop Jun 17, 2024
6 checks passed
@stevez
Copy link
Contributor Author

stevez commented Jun 17, 2024

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 AmsterGet added this to the 5.2.0 milestone Jun 18, 2024
@AmsterGet
Copy link
Member

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?
#205

Thank you in advance!

@stevez
Copy link
Contributor Author

stevez commented Jun 21, 2024

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

@stevez
Copy link
Contributor Author

stevez commented Jun 21, 2024

Check my comment in you pr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants