Android java.net.SocketTimeoutException: Connection timed out

前端 未结 3 1742
礼貌的吻别
礼貌的吻别 2021-01-16 11:24

Recently I have encounter the following error in my program:

11-18 12:30:30.259: W/System.err(21368): java.net.SocketTimeoutException: Connection timed out
1         


        
相关标签:
3条回答
  • 2021-01-16 11:56

    You can use these code snippet for exception haldling:

    HttpURLConnection urlConnection = (HttpURLConnection) callUrl.openConnection();
    urlConnection.setReadTimeout(30000);
    urlConnection.setConnectTimeout(30000);
    
    0 讨论(0)
  • 2021-01-16 12:00

    this type of exception can also occur if firewall blocks the http or https service and to unblock that goto

    firewall->advanced settings -> and check the http or https options and saveenter image description here

    0 讨论(0)
  • 2021-01-16 12:11

    There are two possibilities,

    1)have you checked and tested your connection.

    2)better don't set any connection timeout,if you are setting chose maximum time,,bcos it throws an error,if server didn't response within given time..

    0 讨论(0)
提交回复
热议问题