Timeouts on sonarcloud-scan in bitbucket pipelines

Using bitbucket pipelines to run sonarcloud-scan 4.1.0, previously was running 2.0.0 and started getting the timeout error so tried each version up to 4.1.0, for a private project on sonarcloud to analyze changes on pull request, we are getting random timeout errors, some within the same minute and cannot understand the cause of why these timeouts are happening.

This is the point where the timeout is happening:

(Removed organization and project from URL)

09:44:18.906 INFO  Analysis report generated in 378ms, dir size=1 MB
09:44:19.647 INFO  Analysis report compressed in 740ms, zip size=1 MB
09:44:19.647 INFO  Analysis report generated in /opt/atlassian/pipelines/agent/build/.scannerwork/scanner-report
09:44:19.648 DEBUG Upload report
09:44:19.651 DEBUG --> POST https://sonarcloud.io/api/ce/submit?organization=o&projectKey=k&characteristic=pullRequest%3D8283 (1204926-byte body)
09:45:19.744 DEBUG <-- HTTP FAILED: java.net.SocketTimeoutException: timeout

And this is the error being given:

09:45:19.868 ERROR Error during SonarScanner Engine execution
java.lang.IllegalStateException: Fail to request https://sonarcloud.io/api/ce/submit?organization=o&projectKey=k&characteristic=pullRequest%3D8283
	at com.sonarsource.scanner.engine.webapi.client.HttpConnector.doCall(HttpConnector.java:267)
	at com.sonarsource.scanner.engine.webapi.client.HttpConnector.post(HttpConnector.java:195)
	at com.sonarsource.scanner.engine.webapi.client.HttpConnector.call(HttpConnector.java:141)
	at org.sonar.scanner.http.DefaultScannerWsClient.call(DefaultScannerWsClient.java:54)
	at org.sonar.scanner.report.ReportPublisher.upload(ReportPublisher.java:222)
	at org.sonar.scanner.report.ReportPublisher.execute(ReportPublisher.java:157)
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:185)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.scanner.bootstrap.ScannerContainer.doAfterStart(ScannerContainer.java:454)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:128)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.scanner.bootstrap.ScannerMain.runScannerEngine(ScannerMain.java:143)
	at org.sonar.scanner.bootstrap.ScannerMain.run(ScannerMain.java:58)
	at org.sonar.scanner.bootstrap.ScannerMain.main(ScannerMain.java:42)
Caused by: java.net.SocketTimeoutException: timeout
	at okhttp3.internal.http2.Http2Stream$StreamTimeout.newTimeoutException(Http2Stream.kt:675)
	at okhttp3.internal.http2.Http2Stream$StreamTimeout.exitAndThrowIfTimedOut(Http2Stream.kt:684)
	at okhttp3.internal.http2.Http2Stream$FramingSink.emitFrame(Http2Stream.kt:554)
	at okhttp3.internal.http2.Http2Stream$FramingSink.write(Http2Stream.kt:532)
	at okio.ForwardingSink.write(ForwardingSink.kt:29)
	at okhttp3.internal.connection.Exchange$RequestBodySink.write(Exchange.kt:223)
	at okio.RealBufferedSink.emitCompleteSegments(RealBufferedSink.kt:256)
	at okio.RealBufferedSink.writeAll(RealBufferedSink.kt:195)
	at okhttp3.RequestBody$Companion$asRequestBody$1.writeTo(RequestBody.kt:167)
	at okhttp3.MultipartBody.writeOrCountBytes(MultipartBody.kt:157)
	at okhttp3.MultipartBody.writeTo(MultipartBody.kt:93)
	at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:62)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at com.sonarsource.scanner.engine.webapi.client.OkHttpClientBuilder.addHeaders(OkHttpClientBuilder.java:230)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:34)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.logging.HttpLoggingInterceptor.intercept(HttpLoggingInterceptor.kt:221)
	at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
	at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
	at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
	at com.sonarsource.scanner.engine.webapi.client.HttpConnector.doCall(HttpConnector.java:265)
	... 17 common frames omitted
	Suppressed: okhttp3.internal.http2.StreamResetException: stream was reset: CANCEL
		at okhttp3.internal.http2.Http2Stream.takeHeaders(Http2Stream.kt:148)
		at okhttp3.internal.http2.Http2ExchangeCodec.readResponseHeaders(Http2ExchangeCodec.kt:97)
		at okhttp3.internal.connection.Exchange.readResponseHeaders(Exchange.kt:110)
		at okhttp3.internal.http.CallServerInterceptor.intercept(CallServerInterceptor.kt:93)
		... 33 common frames omitted

This is happening on any size of pull request, ones with 1 file changed and ones with a lot more files changed.

Tried to set different types of timeouts within the yml file but still given the same result.

A post was merged into an existing topic: SonarQube Cloud java.net.SocketTimeoutException: timeout