25 Kasım 2022 Cuma

SocketTimeoutException Sınıfı

Giriş
Şu satırı dahil ederiz
import java.net.SocketTimeoutException;
Örnek - read time out
Elimizde şöyle bir kod olsun
URL url = new URL("https://...");
URLConnection urlConnection = url.openConnection(); urlConnection.setConnectTimeout(20_000); urlConnection.setReadTimeout(5_000); BufferedInputStream is = new BufferedInputStream(urlConnection.getInputStream()); byte[] buffer = new byte[1024]; int n = input.read(buffer);
Exception şöyle
java.net.SocketTimeoutException: Read timed out
Java 8 ile Exception stack trace şöyle
stackTrace = {StackTraceElement[46]@3885} 
 0 = {StackTraceElement@3887} "java.net.SocketInputStream.socketRead0(Native Method)"
 1 = {StackTraceElement@3888} "java.net.SocketInputStream.socketRead(SocketInputStream.java:116)"
 2 = {StackTraceElement@3889} "java.net.SocketInputStream.read(SocketInputStream.java:171)"
 3 = {StackTraceElement@3890} "java.net.SocketInputStream.read(SocketInputStream.java:141)"
 4 = {StackTraceElement@3891} "sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:476)"
 5 = {StackTraceElement@3892} "sun.security.ssl.SSLSocketInputRecord.readFully(SSLSocketInputRecord.java:459)"
 6 = {StackTraceElement@3893} "sun.security.ssl.SSLSocketInputRecord.decodeInputRecord(SSLSocketInputRecord.java:243)"
 7 = {StackTraceElement@3894} "sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:181)"
 8 = {StackTraceElement@3895} "sun.security.ssl.SSLTransport.decode(SSLTransport.java:110)"
 9 = {StackTraceElement@3896} "sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1426)"
 10 = {StackTraceElement@3897} "sun.security.ssl.SSLSocketImpl.readApplicationRecord(SSLSocketImpl.java:1391)"
 11 = {StackTraceElement@3898} "sun.security.ssl.SSLSocketImpl.access$300(SSLSocketImpl.java:73)"
 12 = {StackTraceElement@3899} "sun.security.ssl.SSLSocketImpl$AppInputStream.read(SSLSocketImpl.java:978)"
 13 = {StackTraceElement@3900} "java.io.BufferedInputStream.read1(BufferedInputStream.java:284)"
 14 = {StackTraceElement@3901} "java.io.BufferedInputStream.read(BufferedInputStream.java:345)"
 15 = {StackTraceElement@3902} "sun.net.www.MeteredStream.read(MeteredStream.java:134)"
 16 = {StackTraceElement@3903} "java.io.FilterInputStream.read(FilterInputStream.java:133)"
 17 = {StackTraceElement@3904} "sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3471)"
 18 = {StackTraceElement@3905} "java.io.BufferedInputStream.fill(BufferedInputStream.java:246)"
 19 = {StackTraceElement@3906} "java.io.BufferedInputStream.read1(BufferedInputStream.java:286)"
 20 = {StackTraceElement@3907} "java.io.BufferedInputStream.read(BufferedInputStream.java:345)"
 21 = {StackTraceElement@3908} "java.io.FilterInputStream.read(FilterInputStream.java:107)"

Hiç yorum yok:

Yorum Gönder