How to use HTTP2 - for grpc #262

Closed
opened 2025-12-29 15:19:18 +01:00 by adam · 9 comments
Owner

Originally created by @sergioprates on GitHub (Apr 10, 2020).

Originally assigned to: @StefH on GitHub.

Hi,
In wiremock, since release 2.25.0 has support to make http2 request, but I don't found instructions to do it with WireMock.net. Bellow is the link from release. Is it supported by WireMock.NET? Would be nice if does.

https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!searchin/wiremock-user/http$2F2%7Csort:date/wiremock-user/bxG2-yb-u-Y/YlRq94niBQAJ

Originally created by @sergioprates on GitHub (Apr 10, 2020). Originally assigned to: @StefH on GitHub. Hi, In wiremock, since release 2.25.0 has support to make http2 request, but I don't found instructions to do it with WireMock.net. Bellow is the link from release. Is it supported by WireMock.NET? Would be nice if does. https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!searchin/wiremock-user/http$2F2%7Csort:date/wiremock-user/bxG2-yb-u-Y/YlRq94niBQAJ
adam added the question label 2025-12-29 15:19:18 +01:00
adam closed this issue 2025-12-29 15:19:18 +01:00
Author
Owner

@StefH commented on GitHub (Apr 10, 2020):

I did not add any code specific for http2, so I don't know if this works. I need to check.

@StefH commented on GitHub (Apr 10, 2020): I did not add any code specific for http2, so I don't know if this works. I need to check.
Author
Owner

@kharabasz commented on GitHub (Dec 14, 2020):

@StefH were you ever able to look into the HTTP/2 support (I'm particularly interested in simulating a gRPC api)

@kharabasz commented on GitHub (Dec 14, 2020): @StefH were you ever able to look into the HTTP/2 support (I'm particularly interested in simulating a gRPC api)
Author
Owner

@kharabasz commented on GitHub (Dec 14, 2020):

From a preliminary look - It is possible to add support for Http2 in the Aspnetcore path by mutating the Protocols on the ListenerOptions. It is not as simple as setting Http1OrHttp2 as there are valid use cases for both that option and Http2 which leads me to think that Protocols should be bubbled up as an option on the WireMockServer.

For example (from Microsoft's gRPC docs):

When an HTTP/2 endpoint is configured without TLS, the endpoint's ListenOptions.Protocols must be set to HttpProtocols.Http2. HttpProtocols.Http1AndHttp2 can't be used because TLS is required to negotiate HTTP/2. Without TLS, all connections to the endpoint default to HTTP/1.1, and gRPC calls fail.

I am currently figuring out how to mock gRPC once HTTP2 support is enabled. I think it could work if I had access to return an HttpResponseMessage...

@kharabasz commented on GitHub (Dec 14, 2020): From a preliminary look - It is possible to add support for Http2 in the Aspnetcore path by mutating the Protocols on the ListenerOptions. It is not as simple as setting Http1OrHttp2 as there are valid use cases for both that option and Http2 which leads me to think that Protocols should be bubbled up as an option on the WireMockServer. For example (from Microsoft's gRPC docs): > When an HTTP/2 endpoint is configured without TLS, the endpoint's ListenOptions.Protocols must be set to HttpProtocols.Http2. HttpProtocols.Http1AndHttp2 can't be used because TLS is required to negotiate HTTP/2. Without TLS, all connections to the endpoint default to HTTP/1.1, and gRPC calls fail. I am currently figuring out how to mock gRPC once HTTP2 support is enabled. I think it could work if I had access to return an HttpResponseMessage...
Author
Owner

@kharabasz commented on GitHub (Dec 14, 2020):

To get mocking to work ResponseMessage would require some changes to support TrailingHeaders and support for stream bodies or HttpContent - this would require a fair bit of extension.

@kharabasz commented on GitHub (Dec 14, 2020): To get mocking to work ResponseMessage would require some changes to support TrailingHeaders and support for stream bodies or HttpContent - this would require a fair bit of extension.
Author
Owner

@StefH commented on GitHub (Dec 15, 2020):

Thanks for your investigation.

However, this is not yet on my prio list for now.

@StefH commented on GitHub (Dec 15, 2020): Thanks for your investigation. However, this is not yet on my prio list for now.
Author
Owner

@jzabroski commented on GitHub (Apr 19, 2023):

I looked into this as well. For now, the best approach is probably to use Mountebank server with a Mountebank-grpc plug-in (written in JavaScript) and C# MbDotNet client library. This is obviously a lot of dependencies just to test grpc, but such is life with Google products in my experience: lots and lots of seemingly unnecessary dependencies. - Note: I don't plan to even bother with this as I know my teammates will ridicule me for introducing so many dependencies for stub testing one grpc service one vendor uses.

@jzabroski commented on GitHub (Apr 19, 2023): I looked into this as well. For now, the best approach is probably to use Mountebank server with a Mountebank-grpc plug-in (written in JavaScript) and C# MbDotNet client library. This is obviously a lot of dependencies just to test grpc, but such is life with Google products in my experience: lots and lots of seemingly unnecessary dependencies. - Note: I don't plan to even bother with this as I know my teammates will ridicule me for introducing so many dependencies for stub testing one grpc service one vendor uses.
Author
Owner

@cezarypiatek commented on GitHub (Jun 7, 2023):

I created a proxy generator that converts GRPC requests to HTTP and forwards them to WireMock.
You might give it a shot. Any feedback you can give me is welcome.
The project is available here https://github.com/cezarypiatek/GRPC-Mock-Server

@cezarypiatek commented on GitHub (Jun 7, 2023): I created a proxy generator that converts GRPC requests to HTTP and forwards them to WireMock. You might give it a shot. Any feedback you can give me is welcome. The project is available here https://github.com/cezarypiatek/GRPC-Mock-Server
Author
Owner

@StefH commented on GitHub (Dec 29, 2023):

@jzabroski
@kharabasz
@sergioprates

See https://github.com/WireMock-Net/WireMock.Net/discussions/1045

@StefH commented on GitHub (Dec 29, 2023): @jzabroski @kharabasz @sergioprates See https://github.com/WireMock-Net/WireMock.Net/discussions/1045
Author
Owner

@StefH commented on GitHub (Mar 12, 2024):

It's implemented. See also https://mstack.nl/blogs/wiremock-net-grpc/

@StefH commented on GitHub (Mar 12, 2024): It's implemented. See also https://mstack.nl/blogs/wiremock-net-grpc/
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/WireMock.Net-wiremock#262