Process exited with code 255 - The remote server returned an error: (503) Server Unavailable

Hi @mickaelcaro

Have no issues on curl. I tried both ID/PW and token, both works.

Yes this happens on every Microsoft project. No issues on ReactJS projects.

We do not have a proxy or firewall between the build agent and SQ server.

I tried SonarScanner.MSBuild.exe. Still have the same 503 issue.

Thanks.

And why not using the url with the hostname on your build instead of the private IP ? Does it make sense ? Does it work ?

Host name does work. Microsoft projects is the only time I encounter 503 error.
We tested IP to verify as well. I left the configuration to IP to so I do not have to redact anything.

Are both builds (react and dotnet) run on the same build agent ?

How do you invoke the scanner that analyze the react code ?

Yes all projects (regardless of code base) will run on either 2 Team City Agents. FYI… projects in this context are pure ReactJS or .NET (Framework or Core)

According to your documentation

  • ReactJS I just need to add the “SonarQube Runner” step

  • MS Projects I need to to run “SonarScanner for MSBuild: begin/end…” (MSBuild.SonarQube.Runner.exe) or “SonarQube Begin/End…” (SonarScanner.MSBuild.exe)

Both Scanners (and Scanner for MSBuild is a wrapper over the Scanner CLI, which is ran for React) are making API calls against SQ server, but using different libraries indeed, as the Scanner for MSBuild is written in .NET whereas the Scanner CLI is java.

That being said, they use the same HTTP protocol to achieve that, so i’m really surprise that this work for one and not for the other. Do you pass extra arguments while invoking the Scanner for React directly ?

Is you SQ instance exposed through HTTPS somehow ?

This is what I have in additional arguments for the build build projects. The values that are being set are driven by Team City parameters. I have TC configured to be variable driven. I also confirm everything is being resolve correct. Maybe wrong values but the values I prepopulate is being output.

SonarQube Runner - ReactJS Additional Arguments

-X
-Dsonar.analysis.mode=publish
-Dsonar.coverage.exclusions=**/AssemblyInfo.cs, /Test.cs, **/Tests.cs, **/Test.dll, **/Tests.dll,
-Dsonar.exclusions=
.xml, /AngularJs//
.css, /bootstrap//
.css, */modernizr.js, */bootstrap.css, /jquery//
, Pinnacle.CApi.Registration.OrleansSiloHost/
/, /SwaggerExamples//, /*OrleansSiloHostSettings.cs,/*Readme.md
-Dsonar.log.level=DEBUG
-Dsonar.scm.provider=git
-Dsonar.sourceEncoding=UTF-8
-Dsonar.verbose=true

.NET Additional Arguments
I have SonarQube Runner disabled in the build process. But it would be the same information as above.

“SonarScanner for MSBuild: begin/end…” (MSBuild.SonarQube.Runner.exe)

/d:sonar.verbose=true

“SonarQube Begin/End…” (SonarScanner.MSBuild.exe)
Nothing has been set.

I found this https://github.com/SonarSource/sonar-scanner-msbuild. I cloned to my local and ran the unit test “SonarWebServiceTest” djusted one of the unit test. This is what I found.


Line 327:
if the “Sonar Branch” value has “/ref/head/” I will get the error message that I have been trouble shooting. Fixing the “Sonar Branch” value to “master” the browser url fetches the JSON. Line 327 is happy but the projectFound is false.
With token being pass to my SQ. It seems it does not authenticate or authorize to the project. I did variable the SQ project Key that SQ is using ad Team city is passing.
ws = /api/settings/values?component=

Line 332
ws = /api/settings/values/
URL works through browser. JSON is return. But raises the same exception I am encountering.

The SQ project is “public” the API token I am using is god mode.

This is the result when I put the full ws into the browser
left - /api/settings/values?component=
right - /api/settings/values/

Do you pass manually the sonar.branch.name param on the command line ?

Otherwise yes, i recall that some extensions wraps the refs/heads before the real branch name.

Concerning the exception, is it a 503 as well you are talking about ? or another one ?

How do you do the authentication ?

Thanks.

I was using Team City predefined build parameter - output was “ref/head/master”. I change the parameter value to be hard coded value “master”.

The exception does throw 503 error.

Authentication
I had tried using id/pw and token. You can see in the previous comments screen shot (was only token and you can see the command parameters)

  • 14th post May 2019
  • 22nd post March 2020

In the debugging the code I did use the token and id/pw - same results. Both test were from the unit test SonarWebServiceTest.Credentials()

Yes but 503 is normally not thrown by code, more by the http server in front of all of that, so I’m doubting about the behavior you have.

Can you check your access.log and see if the 503 is returned by one specific route ? Or not at all ?

Thanks.

Update…
I forgot that SQ takes a while to actually log stuff.

> 172.xxx.xx.xxx - - [16/Mar/2020:06:12:07 -0700] "GET /sonar/api/navigation/component?component=Customer_ProfileApi HTTP/1.1" 200 1007 "http://sonarqube.abc.com:9000/sonar/dashboard?id=Customer_ProfileApi" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0" "AXDFlehpdmKUW2M1AAPP"
> 172.xxx.xx.xxx - - [16/Mar/2020:06:12:07 -0700] "GET /sonar/api/components/show?component=Customer_ProfileApi HTTP/1.1" 200 282 "http://sonarqube.abc.com:9000/sonar/dashboard?id=Customer_ProfileApi" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0" "AXDFlehpdmKUW2M1AAPQ"
> 172.xxx.xx.xxx - - [16/Mar/2020:06:12:07 -0700] "GET /sonar/api/project_pull_requests/list?project=Customer_ProfileApi HTTP/1.1" 200 19 "http://sonarqube.abc.com:9000/sonar/dashboard?id=Customer_ProfileApi" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0" "AXDFlehpdmKUW2M1AAPR"
> 172.xxx.xx.xxx - - [16/Mar/2020:06:12:07 -0700] "GET /sonar/api/project_branches/list?project=Customer_ProfileApi HTTP/1.1" 200 165 "http://sonarqube.abc.com:9000/sonar/dashboard?id=Customer_ProfileApi" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0" "AXDFlehpdmKUW2M1AAPS"
> 172.xxx.xx.xxx - - [16/Mar/2020:06:12:07 -0700] "GET /sonar/js/275.m.8774cfa7.chunk.js HTTP/1.1" 200 - "http://sonarqube.abc.com:9000/sonar/dashboard?id=Customer_ProfileApi" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0" "AXDFlehpdmKUW2M1AAPT"
> 172.xxx.xx.xxx - - [16/Mar/2020:06:12:07 -0700] "GET /sonar/api/ce/component?component=Customer_ProfileApi HTTP/1.1" 200 529 "http://sonarqube.abc.com:9000/sonar/dashboard?id=Customer_ProfileApi" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0" "AXDFlehpdmKUW2M1AAPU"
> 172.xxx.xx.xxx - - [16/Mar/2020:06:12:07 -0700] "GET /sonar/api/ce/analysis_status?component=Customer_ProfileApi HTTP/1.1" 200 116 "http://sonarqube.abc.com:9000/sonar/dashboard?id=Customer_ProfileApi" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0" "AXDFlehpdmKUW2M1AAPV"
> 172.xxx.xx.xxx - - [16/Mar/2020:06:12:07 -0700] "GET /sonar/api/metrics/search?ps=500 HTTP/1.1" 200 - "http://sonarqube.abc.com:9000/sonar/dashboard?id=Customer_ProfileApi" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0" "AXDFlehpdmKUW2M1AAPW"
> 172.xxx.xx.xxx - - [16/Mar/2020:06:12:07 -0700] "GET /sonar/api/measures/component?additionalFields=metrics%2Cperiods&component=Customer_ProfileApi&metricKeys=alert_status%2Cquality_gate_details%2Cbugs%2Cnew_bugs%2Creliability_rating%2Cnew_reliability_rating%2Cvulnerabilities%2Cnew_vulnerabilities%2Csecurity_rating%2Cnew_security_rating%2Csecurity_hotspots%2Cnew_security_hotspots%2Ccode_smells%2Cnew_code_smells%2Csqale_rating%2Cnew_maintainability_rating%2Csqale_index%2Cnew_technical_debt%2Ccoverage%2Cnew_coverage%2Cnew_lines_to_cover%2Ctests%2Cduplicated_lines_density%2Cnew_duplicated_lines_density%2Cduplicated_blocks%2Cncloc%2Clines%2Cncloc_language_distribution%2Cprojects%2Cnew_lines HTTP/1.1" 200 - "http://sonarqube.abc.com:9000/sonar/dashboard?id=Customer_ProfileApi" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0" "AXDFlehpdmKUW2M1AAPX"
> 172.xxx.xx.xxx - - [16/Mar/2020:06:12:07 -0700] "GET /sonar/js/339.m.642b8134.chunk.js HTTP/1.1" 200 - "http://sonarqube.abc.com:9000/sonar/dashboard?id=Customer_ProfileApi" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0" "AXDFlehpdmKUW2M1AAPY"
> 172.xxx.xx.xxx - - [16/Mar/2020:06:12:07 -0700] "GET /sonar/js/335.m.1b4cfdd7.chunk.js HTTP/1.1" 200 - "http://sonarqube.abc.com:9000/sonar/dashboard?id=Customer_ProfileApi" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0" "AXDFlehpdmKUW2M1AAPZ"
> 172.xxx.xx.xxx - - [16/Mar/2020:06:12:07 -0700] "GET /sonar/api/project_analyses/search?project=Customer_ProfileApi&ps=3 HTTP/1.1" 200 742 "http://sonarqube.abc.com:9000/sonar/dashboard?id=Customer_ProfileApi" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0" "AXDFlehpdmKUW2M1AAPa"
> 172.xxx.xx.xxx - - [16/Mar/2020:06:12:07 -0700] "GET /sonar/api/rules/search?activation=true&ps=1&qprofile=AWcZZVgOz0KwKq7KLmtl&statuses=DEPRECATED HTTP/1.1" 200 35 "http://sonarqube.abc.com:9000/sonar/dashboard?id=Customer_ProfileApi" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0" "AXDFlehpdmKUW2M1AAPb"
> 172.xxx.xx.xxx - - [16/Mar/2020:06:12:07 -0700] "GET /sonar/api/rules/search?activation=true&ps=1&qprofile=AWcZZVX4z0KwKq7KLmjV&statuses=DEPRECATED HTTP/1.1" 200 35 "http://sonarqube.abc.com:9000/sonar/dashboard?id=Customer_ProfileApi" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0" "AXDFlehpdmKUW2M1AAPc"
> 172.xxx.xx.xxx - - [16/Mar/2020:06:12:07 -0700] "GET /sonar/api/notifications/list HTTP/1.1" 200 397 "http://sonarqube.abc.com:9000/sonar/dashboard?id=Customer_ProfileApi" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0" "AXDFlehpdmKUW2M1AAPg"
> 172.xxx.xx.xxx - - [16/Mar/2020:06:12:07 -0700] "GET /sonar/api/rules/search?activation=true&ps=1&qprofile=AWcZZVsoz0KwKq7KLm9C&statuses=DEPRECATED HTTP/1.1" 200 35 "http://sonarqube.abc.com:9000/sonar/dashboard?id=Customer_ProfileApi" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0" "AXDFlehpdmKUW2M1AAPd"
> 172.xxx.xx.xxx - - [16/Mar/2020:06:12:07 -0700] "GET /sonar/api/project_links/search?projectKey=Customer_ProfileApi HTTP/1.1" 200 12 "http://sonarqube.abc.com:9000/sonar/dashboard?id=Customer_ProfileApi" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0" "AXDFlehpdmKUW2M1AAPe"
> 172.xxx.xx.xxx - - [16/Mar/2020:06:12:07 -0700] "GET /sonar/api/measures/search_history?component=Customer_ProfileApi&metrics=bugs%2Cvulnerabilities%2Csqale_index%2Cduplicated_lines_density%2Cncloc%2Ccoverage%2Ccode_smells&ps=1000 HTTP/1.1" 200 - "http://sonarqube.abc.com:9000/sonar/dashboard?id=Customer_ProfileApi" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0" "AXDFlehpdmKUW2M1AAPf"

I have notice couple of things with the code.

Security Protocol enum was provide but ServicePointManager.SecurityProtocol was never reference after this line.

There is a comment that reference a defect. This does seem to be the same issue I am encountering.

When I try to curl off our build server I have notice that we encounter


if you look at the image from March 2. /d:sonar.login token was provided