前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >gradle java.net.SocketException: Unexpected end of file from server

gradle java.net.SocketException: Unexpected end of file from server

原创
作者头像
望天
发布2020-12-16 18:10:52
2.8K0
发布2020-12-16 18:10:52
举报
文章被收录于专栏:along的开发之旅along的开发之旅
代码语言:javascript
复制
./gradlew build --stacktrace --debug
Downloading https://services.gradle.org/distributions/gradle-4.10.1-all.zip

Exception in thread "main" java.lang.RuntimeException: java.net.SocketException: Unexpected end of file from server
        at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:78)
        at org.gradle.wrapper.Install.createDist(Install.java:47)
        at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
        at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: java.net.SocketException: Unexpected end of file from server
        at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:851)
        at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:678)
        at sun.net.www.protocol.http.HttpURLConnection.doTunneling(HttpURLConnection.java:2055)
        at sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:183)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1564)
        at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
        at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:263)
        at org.gradle.wrapper.Download.downloadInternal(Download.java:59)
        at org.gradle.wrapper.Download.download(Download.java:45)
        at org.gradle.wrapper.Install$1.call(Install.java:60)
        at org.gradle.wrapper.Install$1.call(Install.java:47)
        at org.gradle.wrapper.ExclusiveFileAccessManager.access(ExclusiveFileAccessManager.java:65)
        ... 3 more

很奇怪,url正确,用chrome也能下载。网络看着也ok。

curl看下:

代码语言:javascript
复制
curl -v  https://services.gradle.org/distributions/gradle-4.10.1-all.zip 
*   Trying 104.18.190.9...
* TCP_NODELAY set
* Connected to services.gradle.org (104.18.190.9) port 443 (#0)

> GET /distributions/gradle-4.10.1-all.zip HTTP/1.1
> Host: services.gradle.org
> User-Agent: curl/7.64.1
> Accept: */*
> 
< HTTP/1.1 301 Moved Permanently
< Date: Wed, 16 Dec 2020 09:57:07 GMT
< Transfer-Encoding: chunked
< Connection: keep-alive
< Cache-Control: max-age=3600
< Expires: Wed, 16 Dec 2020 10:57:07 GMT
< Location: https://downloads.gradle-dn.com/distributions/gradle-4.10.1-all.zip
< cf-request-id: 070c9478c50000258d9ea59000000001
< Expect-CT: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
< Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
< Server: cloudflare
< CF-RAY: 602789d46b3d258d-HKG
< 
* Connection #0 to host services.gradle.org left intact
* Closing connection 0

可以看到url 301了,指向的新url是 “https://downloads.gradle-dn.com/distributions/gradle-4.10.1-all.zip”,用这个替换gradle-wrapper.properties中的地址,再次重试,完整下载。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档