{errors":[{"msg":"HTTP method POST is required"}]}

1,795 views
Skip to first unread message

dreaminv...@gmail.com

unread,
Sep 17, 2017, 9:11:24 PM9/17/17
to SonarQube
StackTrace:
java.lang.IllegalStateException: Fail to request http://xxxxx/api/ce/submit?projectKey=x&projectName=y
at org.sonarqube.ws.client.HttpConnector.doCall(HttpConnector.java:212)
at org.sonarqube.ws.client.HttpConnector.call(HttpConnector.java:146)

ErrorMsg:
{"errors":[{"msg":"HTTP method POST is required"}]}

This error doesn't always happen...
After learning the stacktrace, actually, passed to  HttpConnector is Post Method...(HttpConnector.java:175:post method)

looking into the source code: (this is the error position?)

private OkHttpResponse doCall(Request okRequest) {
Call call = okHttpClient.newCall(okRequest);
try {
Response okResponse = call.execute();
return new OkHttpResponse(okResponse);
} catch (IOException e) {
throw new IllegalStateException("Fail to request " + okRequest.url(), e);
}
}

Could you provide any clue about why this happened..? 
(Lastly POST request is converted into GET request)

PS:
I refer to other websites. It said that maybe because of the proxy problem: (http://sonarqube-archive.15.x6.nabble.com/Ant-runner-with-SQ-5-1-td5034256.html)
"a proxy between SQ batch and SQ server that could transform the POST request into a GET?"

dreaminv...@gmail.com

unread,
Sep 17, 2017, 9:16:38 PM9/17/17
to SonarQube
Another StackTrace:
Caused by: java.net.SocketException: Socket closed
at java.net.SocketInputStream.read(SocketInputStream.java:204)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at okio.Okio$2.read(Okio.java:139)
at okio.AsyncTimeout$2.read(AsyncTimeout.java:211)

在 2017年9月18日星期一 UTC+8上午9:11:24,dreaminv...@gmail.com写道:

dreaminv...@gmail.com

unread,
Sep 17, 2017, 9:22:14 PM9/17/17
to SonarQube
SonarQube 5.6
access log:

在 2017年9月18日星期一 UTC+8上午9:16:38,dreaminv...@gmail.com写道:

Eric Hartmann

unread,
Sep 18, 2017, 1:29:42 AM9/18/17
to dreaminv...@gmail.com, SonarQube
Hi,

Please be aware that the standard courtesies (Hi, Thanks, ...) are appreciated in this group.
In order to help you, please, describe your problem : what do you try to achieve ? with which versions of SonarQube, maven, SonarQube scanner, etc. ? 

Regards,

--
You received this message because you are subscribed to the Google Groups "SonarQube" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonarqube+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/c2f67a81-ad2a-4e38-8a93-4f681b49481c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Eric HARTMANN | SonarSource

dreaminv...@gmail.com

unread,
Sep 18, 2017, 4:04:07 AM9/18/17
to SonarQube
Hi,Thanks for your advice..
This time I will try to describe the problem more friendly.

Environment:
Sonarqube 5.6
SonarQube Scanner 3.0.3.778

Problems:
We have integrated SonarQube into our CI toolchain..
Sometimes, unexpected happened like this:
The request are converted into GET method(Before it's POST) when requesting */api/ce/submit/*.
The related message is:

erro msg:
{errors":[{"msg":"HTTP method POST is required"}]}

StackTrace:
java.lang.IllegalStateException: Fail to request http://xxxxx/api/ce/submit?projectKey=x&projectName=y
at org.sonarqube.ws.client.HttpConnector.doCall(HttpConnector.java:212)
at org.sonarqube.ws.client.HttpConnector.post(HttpConnector.java:175)
at org.sonarqube.ws.client.HttpConnector.call(HttpConnector.java:146)

SonarQube web access.log:
refer to:
I found some information about this, but I think it's not the same with my problem.
the post says: "a proxy between SQ batch and SQ server that could transform the POST request into a GET?"

hmmm, you see, code is going through this position:

at org.sonarqube.ws.client.HttpConnector.post(HttpConnector.java:175)

so am I sure that the request method is POST before?
Inside  doCall, POST is changed into GET....
at org.sonarqube.ws.client.HttpConnector.doCall(HttpConnector.java:212)
Hmmm, debug bottleneck here, How could I continue my debugging..? (Or how can I solve this problem)

Look forward to your opinion~

My Best Regards.





在 2017年9月18日星期一 UTC+8下午1:29:42,Eric Hartmann写道:

dreaminv...@gmail.com

unread,
Sep 19, 2017, 1:18:27 AM9/19/17
to SonarQube
I spend 2+ hours in this issue.. Here  I have a guess, it's the okhttp's problem..
its network interceptor redirect from POST  to GET...

But I couldn't know how this happened and where this happened?

在 2017年9月18日星期一 UTC+8下午4:04:07,dreaminv...@gmail.com写道:

Eric Hartmann

unread,
Sep 19, 2017, 2:00:14 AM9/19/17
to dreaminv...@gmail.com, SonarQube
Hi,

If I understood you correctly you have found that there is a proxy that update the POST method to GET ?
In this case, you should ask your network administrator to fix the proxy that does not behave correctly.

Cheers,


For more options, visit https://groups.google.com/d/optout.

dreaminv...@gmail.com

unread,
Sep 19, 2017, 2:10:21 AM9/19/17
to SonarQube
Hi;
Actually no:-)
this problem is not happened in common case. Above conclusion is just my guess...
I am finding a method to prove this guess.


在 2017年9月19日星期二 UTC+8下午2:00:14,Eric Hartmann写道:

Eric Hartmann

unread,
Sep 19, 2017, 2:46:32 AM9/19/17
to dreaminv...@gmail.com, SonarQube
Hi,

If your computer is not configured with a proxy (that should be easy to check), it will be really hard to know if there is a reverse proxy or a firewall that manipulate http requests without asking to a network administrator.

Cheers,


For more options, visit https://groups.google.com/d/optout.

dreaminv...@gmail.com

unread,
Sep 19, 2017, 6:45:53 AM9/19/17
to SonarQube
hmmm, could you point the concrete code position where produces the access.log?(Maybe it can give me some inspirations)
(T-T: I am waiting  for this issue reproduced in the production-environment.?)


在 2017年9月19日星期二 UTC+8下午2:46:32,Eric Hartmann写道:

Eric Hartmann

unread,
Sep 19, 2017, 8:22:15 AM9/19/17
to dreaminv...@gmail.com, SonarQube
Hi,

The access.log file is generated by Tomcat that is embedded into SonarQube, you can customize the log format with sonar.properties file (have a look at sonar.web.accessLogs.pattern).

Cheers 


For more options, visit https://groups.google.com/d/optout.

dreaminv...@gmail.com

unread,
Sep 20, 2017, 6:15:22 AM9/20/17
to SonarQube
Hi,
T-T, after looking into the access.log, I found that the request is behind the nginx:

1. Open the nginx conf file, I don't find any rewrite rule

2. Open the nginx error log, something suspicious like this: "2017/09/13 19:35:18 [error] 122157#122157: *126090038 upstream prematurely closed connection while reading response header from upstream, client ****" 
this has any relationship with rewrite POST -> GET

3. Open the nginx access.log,I can see the request has been GET request...and I always see this:
"GET /favicon.ico HTTP/1.1" 302 161 "http://***/api/ce/submit?***"
I just learn nginx , so I can't see much thing from these log contents.
(I guess it's the nginx's load balance's problem?)

Based on these contents, could I yield some conclusions why POST converted into GET?
Or I adjust ngnix configuration(like adjust timeout value) to avoid this problem?






在 2017年9月19日星期二 UTC+8下午8:22:15,Eric Hartmann写道:

Eric Hartmann

unread,
Sep 20, 2017, 10:05:19 AM9/20/17
to dreaminv...@gmail.com, SonarQube
Hi,

In order to go further and find the issue.
Can you describe your setup ?
  • So you have a reverse proxy (nginx) :
    • Is this reverse proxy in the same server as SonarQube ?
    • Can you post your nginx configuration ?
    • Can you post your SonarQube configuration ?
    • Can you run " curl -I http://xxxxx " where xxxxx is your URL of the server
  • Which tool is generating your IllegalStateException ? Maven, SonarQube scanner ? what is the version of this tool ?
Cheers,


For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages