Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected HTTP/1.x request: OPTIONS #581

Closed
cinling opened this issue Sep 7, 2021 · 7 comments
Closed

Unexpected HTTP/1.x request: OPTIONS #581

cinling opened this issue Sep 7, 2021 · 7 comments
Labels
bug Something does not work as expected feedback required Information are missing or feedback for suggestions is requested

Comments

@cinling
Copy link

cinling commented Sep 7, 2021

The context

What do you wish to achieve?

  1. Let Server communicate with grpc-web
    or
  2. grpc-server-spring-boot-starter is compatible with http/1.x protocol

The bug

What's the problem? What's not working? What do you expect to happen.

Stacktrace and logs

io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2Exception: Unexpected HTTP/1.x request: OPTIONS /net.cinling.appbill.grpc.UserProto/IsMailReg 
	at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2Exception.connectionError(Http2Exception.java:103) ~[grpc-netty-shaded-1.37.0.jar:1.37.0]
	at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandler$PrefaceDecoder.readClientPrefaceString(Http2ConnectionHandler.java:302) ~[grpc-netty-shaded-1.37.0.jar:1.37.0]
	at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandler$PrefaceDecoder.decode(Http2ConnectionHandler.java:239) ~[grpc-netty-shaded-1.37.0.jar:1.37.0]
	at io.grpc.netty.shaded.io.netty.handler.codec.http2.Http2ConnectionHandler.decode(Http2ConnectionHandler.java:438) ~[grpc-netty-shaded-1.37.0.jar:1.37.0]
	at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.decodeRemovalReentryProtection(ByteToMessageDecoder.java:501) ~[grpc-netty-shaded-1.37.0.jar:1.37.0]
	at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:440) ~[grpc-netty-shaded-1.37.0.jar:1.37.0]
	at io.grpc.netty.shaded.io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:276) ~[grpc-netty-shaded-1.37.0.jar:1.37.0]
	at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[grpc-netty-shaded-1.37.0.jar:1.37.0]
	at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[grpc-netty-shaded-1.37.0.jar:1.37.0]
	at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:357) ~[grpc-netty-shaded-1.37.0.jar:1.37.0]
	at io.grpc.netty.shaded.io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410) ~[grpc-netty-shaded-1.37.0.jar:1.37.0]
	at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:379) ~[grpc-netty-shaded-1.37.0.jar:1.37.0]
	at io.grpc.netty.shaded.io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:365) ~[grpc-netty-shaded-1.37.0.jar:1.37.0]
	at io.grpc.netty.shaded.io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919) ~[grpc-netty-shaded-1.37.0.jar:1.37.0]
	at io.grpc.netty.shaded.io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:166) ~[grpc-netty-shaded-1.37.0.jar:1.37.0]
	at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:714) ~[grpc-netty-shaded-1.37.0.jar:1.37.0]
	at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:650) ~[grpc-netty-shaded-1.37.0.jar:1.37.0]
	at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:576) ~[grpc-netty-shaded-1.37.0.jar:1.37.0]
	at io.grpc.netty.shaded.io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) ~[grpc-netty-shaded-1.37.0.jar:1.37.0]
	at io.grpc.netty.shaded.io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[grpc-netty-shaded-1.37.0.jar:1.37.0]
	at io.grpc.netty.shaded.io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[grpc-netty-shaded-1.37.0.jar:1.37.0]
	at io.grpc.netty.shaded.io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[grpc-netty-shaded-1.37.0.jar:1.37.0]
	at java.base/java.lang.Thread.run(Thread.java:831) ~[na:na]

Steps to Reproduce

Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

The application's environment

Which versions do you use?

  • Spring (boot):2.5.4
  • grpc-java:1.40.1
  • grpc-spring-boot-starter:2.12.0.RELEASE
  • java: version + architecture (64bit?). OpenJDK 64-Bit Server VM (build 16.0.2+7-67, mixed mode, sharing)
  • Other relevant libraries...
  • grpc Client[node.js]:
  • @ngx-grpc/* 2.3.0
  • google-protobuf 3.17.3
  • grpc-web 1.2.1

Additional context

  • Did it ever work before?
    NO
  • Do you have a demo?
    NO
@cinling cinling added the bug Something does not work as expected label Sep 7, 2021
@ST-DDT ST-DDT added the feedback required Information are missing or feedback for suggestions is requested label Sep 7, 2021
@ST-DDT
Copy link
Collaborator

ST-DDT commented Sep 7, 2021

Please provide steps to reproduce the error otherwise we cannot help you.

A quick google search revealed the following issue: grpc/grpc-web#432
AFAICT grpc-java does not support HTTP/1.x requests, if that's the case there is nothing we can do in this regard other than: #207 (far future)

@cinling
Copy link
Author

cinling commented Sep 8, 2021

I tried to use nginx as an intermediate proxy, now it can run

@cinling cinling closed this as completed Sep 8, 2021
@Edwin-Xu
Copy link

Edwin-Xu commented Dec 4, 2022

m

@eum2o
Copy link

eum2o commented Mar 29, 2023

@cinling can you please elaborate on this a little?

How did you configure Nginx? I only know that you can forward certain calls to arbitrary destinations. But I don't get how you use Nginx to forward HTTP/1.1 (probably JSON?) requests to an HTTP/2 gRPC endpoint.

@cinling
Copy link
Author

cinling commented Mar 29, 2023 via email

@wbartussek
Copy link

I'm having exactly the same issue as described by cinling above. Unfortunately cinling's answer being on vacation is funny but not very helpful. Has anybody a solution that is a bit more explicit than cinling's answer "I tried to use nginx as an intermediate proxy, now it can run"?

@cinling
Copy link
Author

cinling commented Jun 10, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something does not work as expected feedback required Information are missing or feedback for suggestions is requested
Projects
None yet
Development

No branches or pull requests

5 participants