seratch / notion-sdk-jvm

A Notion SDK for Any JVM Language
https://developers.notion.com/
MIT License
135 stars 25 forks source link

Configurable HttpClient properties #84

Closed ksharma96 closed 1 year ago

ksharma96 commented 1 year ago

We ran into an issue with an on prem server. It takes > 3 seconds in some situations to connect to the Notion endpoints and the SDK throws a Null Pointer Exception. Have a look at the logs below:

image

Can the SDK's NotionClient/NotionHttpClient expose some way to configure the below two properties please @seratch ?

private val connectTimeoutMillis: Int = 3_000,
private val readTimeoutMillis: Int = 30_000,

These reside inside the class HttpUrlConnNotionHttpClient . Would love to have raised a pull request for the same myself, but am just not familiar with Kotlin. Cheers.

seratch commented 1 year ago

Hi @ksharma96, you can manually instantiate the http client and pass it to NotionClient constructor like it does here: https://github.com/seratch/notion-sdk-jvm/blob/v1.8.0/core/src/main/kotlin/notion/api/v1/NotionClient.kt#L20

Thanks for asking this! Since I've provided an answer to your question, let me close this issue now.

ksharma96 commented 1 year ago

Thanks for the prompt response!

ksharma96 commented 1 year ago

Hey @seratch - the only way exposed in Java to set the client is via setHttpClient method as shown below.

image

Also, the constructor only takes a string as the input for the token in Java.

image

So as of now, I'm not able to manually instantiate the http client and pass it to the Constructor, can you please help with some inputs as to what I can do about this? I just want to set the connect_timeout and read_timeout to my customized values.

seratch commented 1 year ago

@ksharma96 Here is an example:

package example;

import notion.api.v1.NotionClient;
import notion.api.v1.http.HttpUrlConnNotionHttpClient;

public class Test {
    public static void main(String[] args) {
        NotionClient client = new NotionClient();
        client.setHttpClient(new HttpUrlConnNotionHttpClient(
                10_000,
                60_000
        ));
    }
}