walklown commented on PR #14026: URL: https://github.com/apache/dubbo/pull/14026#issuecomment-2076889743
> > > Test `org.apache.dubbo.demo.provider.ApiProvider` with curl: > > > ``` > > > curl.exe -v --http2 -k -H "Content-Type: application/json" -d '"asd"' http://127.0.0.1:50051/org.apache.dubbo.demo.GreeterService/sayHelloAsync > > > ``` > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > but upgrade failed, could you please take a look?  > > > > > > Because you specified a http scheme (and not https), and asked curl to use HTTP/2, then curl will attempt to perform a HTTP/1.1 upgrade to HTTP/2, as can be seen from the logs. > > Typical HTTP/1.1 upgrades are performed using GET, not POST, notably the HTTP/1.1 upgrade to WebSocket. > > The server does not seem to be prepared to accept a POST with a body as an attempt to upgrade and replies with 413 because it does not expect a body. > > If you try a GET without body it will likely succeed. > > Alternatively, if you know that port 8889 accepts prior-knowledge clear-text HTTP/2 (that is, you can send directly HTTP/2 bytes to that port without having to perform a HTTP/1.1 upgrade), you can try: > > `curl -v --http2-prior-knowledge -X POST -k -H "content-type:application/json" -d '["myFirstParameter"]' http://127.0.0.1:50052/org.apache.dubbo.springboot.demo.DemoService/sayHello` > >  > > `$ curl -v --http2-prior-knowledge -X POST -k -H "content-type:application/json" -d '["myFirstParameter"]' http://127.0.0.1:50052/org.apache.dubbo.springboot.demo.DemoService/sayHello Note: Unnecessary use of -X or --request, POST is already inferred. > > > > * Trying 127.0.0.1:50052... > > * Connected to 127.0.0.1 (127.0.0.1) port 50052 > > * [HTTP/2] [1] OPENED stream for http://127.0.0.1:50052/org.apache.dubbo.springboot.demo.DemoService/sayHello > > * [HTTP/2] [1] [:method: POST] > > * [HTTP/2] [1] [:scheme: http] > > * [HTTP/2] [1] [:authority: 127.0.0.1:50052] > > * [HTTP/2] [1] [:path: /org.apache.dubbo.springboot.demo.DemoService/sayHello] > > * [HTTP/2] [1] [user-agent: curl/8.5.0] > > * [HTTP/2] [1] [accept: _/_] > > * [HTTP/2] [1] [content-type: application/json] > > * [HTTP/2] [1] [content-length: 20] > > > > > POST /org.apache.dubbo.springboot.demo.DemoService/sayHello HTTP/2 > > > Host: 127.0.0.1:50052 > > > User-Agent: curl/8.5.0 > > > Accept: _/_ > > > content-type:application/json > > > Content-Length: 20 > > > > > > < HTTP/2 200 < te: trailers < content-type: application/json < > > > > * Connection #0 to host 127.0.0.1 left intact > > "Hello myFirstParameter"` > > > > Test `org.apache.dubbo.demo.provider.ApiProvider` with curl: > > > ``` > > > curl.exe -v --http2 -k -H "Content-Type: application/json" -d '"asd"' http://127.0.0.1:50051/org.apache.dubbo.demo.GreeterService/sayHelloAsync > > > ``` > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > but upgrade failed, could you please take a look?  > > > > > > Because you specified a http scheme (and not https), and asked curl to use HTTP/2, then curl will attempt to perform a HTTP/1.1 upgrade to HTTP/2, as can be seen from the logs. > > Typical HTTP/1.1 upgrades are performed using GET, not POST, notably the HTTP/1.1 upgrade to WebSocket. > > The server does not seem to be prepared to accept a POST with a body as an attempt to upgrade and replies with 413 because it does not expect a body. > > If you try a GET without body it will likely succeed. > > Alternatively, if you know that port 8889 accepts prior-knowledge clear-text HTTP/2 (that is, you can send directly HTTP/2 bytes to that port without having to perform a HTTP/1.1 upgrade), you can try: > > `curl -v --http2-prior-knowledge -X POST -k -H "content-type:application/json" -d '["myFirstParameter"]' http://127.0.0.1:50052/org.apache.dubbo.springboot.demo.DemoService/sayHello` > >  > > `$ curl -v --http2-prior-knowledge -X POST -k -H "content-type:application/json" -d '["myFirstParameter"]' http://127.0.0.1:50052/org.apache.dubbo.springboot.demo.DemoService/sayHello Note: Unnecessary use of -X or --request, POST is already inferred. > > > > * Trying 127.0.0.1:50052... > > * Connected to 127.0.0.1 (127.0.0.1) port 50052 > > * [HTTP/2] [1] OPENED stream for http://127.0.0.1:50052/org.apache.dubbo.springboot.demo.DemoService/sayHello > > * [HTTP/2] [1] [:method: POST] > > * [HTTP/2] [1] [:scheme: http] > > * [HTTP/2] [1] [:authority: 127.0.0.1:50052] > > * [HTTP/2] [1] [:path: /org.apache.dubbo.springboot.demo.DemoService/sayHello] > > * [HTTP/2] [1] [user-agent: curl/8.5.0] > > * [HTTP/2] [1] [accept: _/_] > > * [HTTP/2] [1] [content-type: application/json] > > * [HTTP/2] [1] [content-length: 20] > > > > > POST /org.apache.dubbo.springboot.demo.DemoService/sayHello HTTP/2 > > > Host: 127.0.0.1:50052 > > > User-Agent: curl/8.5.0 > > > Accept: _/_ > > > content-type:application/json > > > Content-Length: 20 > > > > > > < HTTP/2 200 < te: trailers < content-type: application/json < > > > > * Connection #0 to host 127.0.0.1 left intact > > "Hello myFirstParameter"` > > There is no documentation mentioned that methods other than GET are not supported. I think it might be because you haven't set maxContentLength https://github.com/netty/netty/blob/4379f0b92dc1ae375bba9afa1c279b5aa867a3eb/codec-http/src/main/java/io/netty/handler/codec/http/HttpServerUpgradeHandler.java#L190 > > --http2-prior-knowledge will skip negotiation, therefore this test is meaningless. You are right, thanks for the guidance. I have submitted a fix -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@dubbo.apache.org For additional commands, e-mail: notifications-h...@dubbo.apache.org