I am using FacebookClient class and publish function when requesting. I want to shorten timeout times. How can I do it?
You have to extend the DefaultWebRequstor
class and override the customizeConnection
method. There you can modify the connection
object and set your custom timeout.
@Override
protected void customizeConnection(HttpURLConnection connection) {
connection.setReadTimeout(YOUR_VALUE_IN_MS);
}
Afterwards you have to use this custom web requestor in the constructor of the DefaultFacebookClient class.
FacebookClient client =
new DefaultFacebookClient(ACCESS_TOKEN,
new CustomWebRequestor(), // your requestor
new DefaultJsonMapper(),
Version.LATEST);
And you're done. With this method you can modify the connection even further.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.