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

When Creating Http Client Allow SocketTimeout & ConnectionTimeout & ConnectionRequestTimeout To Be Set Externally #17

Open
bhreinb opened this issue Mar 27, 2019 · 4 comments

Comments

@bhreinb
Copy link

bhreinb commented Mar 27, 2019

At the moment the default timeout values within the following source file

https://github.com/poynt/postman-runner/blob/master/src/main/java/co/poynt/postman/PostmanRequestRunner.java are

SocketTimeout -> 60000
ConnectTimeout -> 5000
ConnectionRequestTimeout -> 60000

in some circumstances that timeout isn't sufficient for some web services we test against so it would be great if their was a means to override these default values.

@vchau
Copy link
Contributor

vchau commented May 9, 2019

If you are programmatically calling, would accepting a http client provider be sufficient?

@bhreinb
Copy link
Author

bhreinb commented May 9, 2019

Hi @vchau

I'm slightly confused as to what you mean here. The http client gets created for me through method

public boolean run(PostmanItem item, PostmanRunResult runResult) {

from here

https://github.com/poynt/postman-runner/blob/master/src/main/java/co/poynt/postman/PostmanRequestRunner.java#L76

which in turn invokes

protected CloseableHttpClient createHttpClient() {

so the outer method run doesn't return a http client. So I'm assuming to accept a http client some refactor of the existing code would need to be done? If that was done then I assume the http client would be created without the default request config, which likely would be done by a consumer of the library right (me in this case)?

Another very quick fix potentially could be

public static int SOCKET_TIMEOUT = 60000;
public static int CONNECT_TIMEOUT = 5000;
public static int CONNECTION_REQUEST_TIMEOUT = 5000;

or nicer again through the use of getters and setters.

@vchau
Copy link
Contributor

vchau commented May 18, 2019

Sorry, I meant we can change the PostmanRequestRunner constructor to also take an optional http client provider. That way, you can pass in your own http client. For example:

public interface HttpClientProvider {

	CloseableHttpClient getHttpClient();

}

public PostmanRequestRunner(PostmanVariables var, boolean haltOnError, HttpClientProvider provider) {
		...
}

@bhreinb
Copy link
Author

bhreinb commented Jul 6, 2019

Hi @vchau

Yeah this could work. If you don't mind please change the constructor to add a Http client please.

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

No branches or pull requests

2 participants