GithubAction SelfHosted Runner launch error SocketException: Connection reset

  android, docker, github-actions, gradle, gradlew

We are configuring a self-hosted android runner for GithubActions, but when we run some command of gradlew, it crashes/stops sending an error connection reset.

Our docker file contains the basic for a android runner (few lines of code for gradle and sdk installation. the tools are also installed properly).

# Gradle
ENV GRADLE_VERSION 7.0.2
ENV GRADLE_HOME="/opt/gradle"
ENV GRADLE_SDK_URL https://services.gradle.org/distributions/gradle-${GRADLE_VERSION}-bin.zip
RUN curl -sSL "${GRADLE_SDK_URL}" -o gradle-${GRADLE_VERSION}-bin.zip  
    && unzip -q gradle-${GRADLE_VERSION}-bin.zip -d ${GRADLE_HOME}  
    && rm -rf gradle-${GRADLE_VERSION}-bin.zip 
    && chmod +775 /opt/gradle
    
ENV PATH ${GRADLE_HOME}/bin:$PATH
        # Install Android SDK
RUN echo "SDK tools ${ANDROID_SDK_TOOLS_VERSION}" 
    && cd /opt 
    && chmod +775 . 
    && wget -q "https://dl.google.com/android/repository/commandlinetools-linux-${ANDROID_SDK_TOOLS_VERSION}_latest.zip" -O android-commandline-tools.zip 
    && mkdir -p ${ANDROID_SDK_HOME}/cmdline-tools 
    && unzip -q android-commandline-tools.zip -d /tmp/ 
    && mv /tmp/cmdline-tools/ ${ANDROID_SDK_HOME}/cmdline-tools/latest 
    && rm android-commandline-tools.zip && ls -la ${ANDROID_SDK_HOME}/cmdline-tools/latest/

Then when in the workflow we do some ./gradlew command it crashes.

some example commands that crash:

> ./gradlew --version

> ./gradlew app:assembleBetaRelease --offline

Always same Error log:

Run ./gradlew --version
Downloading https://services.gradle.org/distributions/gradle-7.0.2-all.zip

Exception in thread "main" java.lang.RuntimeException: java.net.SocketException: Connection reset
    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: Connection reset
    at java.base/java.net.SocketInputStream.read(SocketInputStream.java:186)
    at java.base/java.net.SocketInputStream.read(SocketInputStream.java:140)
    at java.base/sun.security.ssl.SSLSocketInputRecord.read(SSLSocketInputRecord.java:478)
    at java.base/sun.security.ssl.SSLSocketInputRecord.readHeader(SSLSocketInputRecord.java:472)
    at java.base/sun.security.ssl.SSLSocketInputRecord.decode(SSLSocketInputRecord.java:160)
    at java.base/sun.security.ssl.SSLTransport.decode(SSLTransport.java:111)
    at java.base/sun.security.ssl.SSLSocketImpl.decode(SSLSocketImpl.java:1426)
    at java.base/sun.security.ssl.SSLSocketImpl.readHandshakeRecord(SSLSocketImpl.java:1336)
    at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:450)
    at java.base/sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:421)
    at java.base/sun.net.www.protocol.https.HttpsClient.afterConnect(HttpsClient.java:572)
    at java.base/sun.net.www.protocol.https.AbstractDelegateHttpsURLConnection.connect(AbstractDelegateHttpsURLConnection.java:197)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1592)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1520)
    at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:250)
    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
Error: Process completed with exit code 1.

It seems that tries to download Gradle, but it exist previously in dockerfile.

Did we forget some configuration in dockerfile or something similar?

Source: Docker Questions

LEAVE A COMMENT