HttpURLConnection setConnectTimeout() has no effect

前端 未结 8 1480
刺人心
刺人心 2020-12-04 21:40

I\'m connecting to a simple RSS feed using HTTPUrlConnection. It works perfectly. I\'d like to add a timeout to the connection since I don\'t want my app hanging in the even

相关标签:
8条回答
  • 2020-12-04 22:32

    A zero value means infinit time out, which means connection must occure and normally zero is default:

    connection.setConnectTimeout(0);
    connection.setReadTimeout(0);
    

    refer to here

    0 讨论(0)
  • 2020-12-04 22:33
    http.setConnectTimeout(15000);
    http.setReadTimeout(15000);
    
    0 讨论(0)
提交回复
热议问题