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 setting UrlConnection timeout #254

Closed
MasterDDT opened this issue Aug 25, 2019 · 4 comments
Closed

Allow setting UrlConnection timeout #254

MasterDDT opened this issue Aug 25, 2019 · 4 comments
Labels

Comments

@MasterDDT
Copy link

MasterDDT commented Aug 25, 2019

Which SDK version are you using?

4.0.2

What's the issue?

Requests get stuck here forever

Thread ID	Thread Name	Thread State	Thread Locks
127	Executor task launch worker for task 1877	RUNNABLE	Monitor(sun.net.www.protocol.https.HttpsURLConnectionImpl@190634379}), Lock(java.util.concurrent.ThreadPoolExecutor$Worker@1609039339}), Monitor(sun.net.www.protocol.https.DelegateHttpsURLConnection@1674919037}), Monitor(java.lang.Object@2105931076}), Monitor(java.lang.Object@1572391454})
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
java.net.SocketInputStream.read(SocketInputStream.java:171)
java.net.SocketInputStream.read(SocketInputStream.java:141)
sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
sun.security.ssl.InputRecord.read(InputRecord.java:503)
sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983) => holding Monitor(java.lang.Object@1572391454})
sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385) => holding Monitor(java.lang.Object@2105931076})
sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)
sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397)
sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:559)
sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:185)
sun.net.www.protocol.http.HttpURLConnection.getOutputStream0(HttpURLConnection.java:1334) => holding Monitor(sun.net.www.protocol.https.DelegateHttpsURLConnection@1674919037})
sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:1309) => holding Monitor(sun.net.www.protocol.https.DelegateHttpsURLConnection@1674919037})
sun.net.www.protocol.https.HttpsURLConnectionImpl.getOutputStream(HttpsURLConnectionImpl.java:259) => holding Monitor(sun.net.www.protocol.https.HttpsURLConnectionImpl@190634379})
com.facebook.ads.sdk.APIRequest$DefaultRequestExecutor.sendPost(APIRequest.java:544)
com.facebook.ads.sdk.BatchRequest.executeInternal(BatchRequest.java:142)
com.facebook.ads.sdk.BatchRequest.execute(BatchRequest.java:76)

If we could set the default connection timeout, we could avoid the call getting stuck and have it fail (so it would retry lower in the stack).

Steps/Sample code to reproduce the issue

Not sure how to reproduce. We commonly get the "(19) User request limit reached" error and retry it, but usually retry works. Once every few days, we get a stuck request.

Observed Results:

The issue was already seen here: #69 (cc @kogitant)

Expected Results:

Be able to set a connection timeout for all requests through the SDK. Note I do not want to set the global JVM flag -Dsun.net.client.defaultConnectTimeout because I have many other things running in the process.

If the caller can somehow pass down the timeout value, then here we could call con.setConnectTimeout

con.setRequestProperty("Content-Type","application/x-www-form-urlencoded");

@MasterDDT
Copy link
Author

MasterDDT commented Aug 29, 2019

cc @daphyFB @JiamingFB

@stale
Copy link

stale bot commented Jan 14, 2020

Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Stale label Jan 14, 2020
@stale
Copy link

stale bot commented Jan 21, 2020

Closing this issue after a prolonged period of inactivity. If this issue is still present in the latest release, please feel free to create a new issue with up-to-date information.

@stale stale bot closed this as completed Jan 21, 2020
@feizhiyang
Copy link

feizhiyang commented Dec 1, 2021

I had a same issue similar to the issue of MasterDDT.
How should i solve the issue?
I suggest that the params of connectTime and readTime support to user-defined.

issue detail:
"thread-pool-2" #9901 prio=5 os_prio=0 cpu=516.49ms elapsed=434525.53s allocated=480M defined_classes=8 tid=0x00007fd4d416a000 nid=0x26bb runnable [0x00007fd466ef3000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(java.base@11.0.11/Native Method)
at java.net.SocketInputStream.socketRead(java.base@11.0.11/SocketInputStream.java:115)
at java.net.SocketInputStream.read(java.base@11.0.11/SocketInputStream.java:168)
at java.net.SocketInputStream.read(java.base@11.0.11/SocketInputStream.java:140)
at sun.security.ssl.SSLSocketInputRecord.read(java.base@11.0.11/SSLSocketInputRecord.java:478)
at sun.security.ssl.SSLSocketInputRecord.readHeader(java.base@11.0.11/SSLSocketInputRecord.java:472)
at sun.security.ssl.SSLSocketInputRecord.bytesInCompletePacket(java.base@11.0.11/SSLSocketInputRecord.java:70)
at sun.security.ssl.SSLSocketImpl.readApplicationRecord(java.base@11.0.11/SSLSocketImpl.java:1364)
at sun.security.ssl.SSLSocketImpl$AppInputStream.read(java.base@11.0.11/SSLSocketImpl.java:973)
at java.io.BufferedInputStream.fill(java.base@11.0.11/BufferedInputStream.java:252)
at java.io.BufferedInputStream.read1(java.base@11.0.11/BufferedInputStream.java:292)
at java.io.BufferedInputStream.read(java.base@11.0.11/BufferedInputStream.java:351)
- locked <0x000000009b249738> (a java.io.BufferedInputStream)
at sun.net.www.http.HttpClient.parseHTTPHeader(java.base@11.0.11/HttpClient.java:754)
at sun.net.www.http.HttpClient.parseHTTP(java.base@11.0.11/HttpClient.java:689)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(java.base@11.0.11/HttpURLConnection.java:1615)
- locked <0x000000009b283d00> (a sun.net.www.protocol.https.DelegateHttpsURLConnection)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(java.base@11.0.11/HttpURLConnection.java:1520)
- locked <0x000000009b283d00> (a sun.net.www.protocol.https.DelegateHttpsURLConnection)
at java.net.HttpURLConnection.getResponseCode(java.base@11.0.11/HttpURLConnection.java:527)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(java.base@11.0.11/HttpsURLConnectionImpl.java:334)
at com.facebook.ads.sdk.APIRequest.readResponse(APIRequest.java:287)
at com.facebook.ads.sdk.APIRequest.access$100(APIRequest.java:52)
at com.facebook.ads.sdk.APIRequest$DefaultRequestExecutor.sendPost(APIRequest.java:588)
at com.facebook.ads.sdk.APIRequest$DefaultRequestExecutor.execute(APIRequest.java:520)
at com.facebook.ads.sdk.APIRequest.executeInternal(APIRequest.java:197)
at com.facebook.ads.sdk.AdAccount$APIRequestCreateAdImage.execute(AdAccount.java:4225)
at com.facebook.ads.sdk.AdAccount$APIRequestCreateAdImage.execute(AdAccount.java:4220)

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

No branches or pull requests

2 participants