0
我總是收到「Error Connecting to $ {url}」消息?Groovy中HttpURLConnection的連接超時
任何人都可以讓我看看我的錯誤嗎?
def url = new URL("https://www.google.com")
HttpURLConnection connection = (HttpURLConnection) url.openConnection()
connection.setRequestMethod("GET")
// connection.setConnectTimeout(10000)
connection.connect()
if (connection.responseCode == 200 || connection.responseCode == 201) {
def returnMessage = connection.content
//print out the full response
println returnMessage
} else {
println "Error Connecting to " + url
}
|錯誤2012-07-05 00:04:05,950 [http-bio-8080-exec-6] ERROR errors.GrailsExceptionResolver - 處理請求時發生ConnectException:[GET]/CopperApplications/urlTracker連接超時:連接。 Stacktrace如下:消息:連接超時:connec
你實際上得到了什麼'responseCode'?這將是有用的信息來解決這個問題。 – David
|錯誤2012-07-05 00:04:05,950 [http-bio-8080-exec-6] ERROR errors.GrailsExceptionResolver - 處理請求時發生ConnectException:[GET]/CopperApplications/urlTracker 連接超時:連接。 Stacktrace如下: 消息:連接超時:連接 – sam1132
@ sam1132 - 請編輯您的問題以包含該錯誤消息。這對於試圖回答你的問題的人來說是有用的,應該成爲問題的一部分,而不僅僅是在評論中。 – David