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

An HTTP/2 + HTTPS request to mockserver made by curl hangs indefinitely #1933

Open
pavelrappo opened this issue Mar 5, 2025 · 0 comments
Open

Comments

@pavelrappo
Copy link

Describe the issue

An HTTP/2 + HTTPS request to mockserver made by curl hangs indefinitely.

What you are trying to do

Trying to record a curl request to create an expectation from it.

MockServer and other versions

  1. <dependency>
       <groupId>org.mock-server</groupId>
       <artifactId>mockserver-netty-no-dependencies</artifactId>
       <version>5.15.0</version>
    </dependency>
  2. curl 8.7.1 (x86_64-apple-darwin24.0) libcurl/8.7.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.63.0
    Release-Date: 2024-03-27
    Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
    Features: alt-svc AsynchDNS GSS-API HSTS HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM SPNEGO SSL threadsafe UnixSockets
    
  3. openjdk version "21.0.6" 2025-01-21
    OpenJDK Runtime Environment Homebrew (build 21.0.6)
    OpenJDK 64-Bit Server VM Homebrew (build 21.0.6, mixed mode, sharing)
    

To Reproduce

  1. How you are running MockServer (i.e maven plugin, docker, etc)

    import java.time.Duration;
    import org.mockserver.integration.ClientAndServer;
    
    public class Test {
       public static void main(String[] args) {
           try (var unused = ClientAndServer.startClientAndServer()) {
               try {
                   Thread.sleep(Duration.ofMinutes(1));
               } catch (InterruptedException ignored) { }
           }
       }
    }
  2. Code you used to create expectations
    No expectations have been created; it's the recording stage.

  3. What error you saw

    % time curl -k --proxy localhost:56634 https://www.google.com
    curl: (16) Remote peer returned unexpected data while we expected SETTINGS frame.  Perhaps, peer does not support HTTP/2 properly.
    curl -k --proxy localhost:56634 https://www.google.com  0.01s user 0.01s system 0% cpu 45.187 total
    

Expected behaviour

The same as with HTTP schema:

% time curl --proxy localhost:56503 http://google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/">here</A>.
</BODY></HTML>
curl --proxy localhost:56503 http://google.com  0.00s user 0.00s system 9% cpu 0.097 total

MockServer Log

2025-03-05 20:50:09 5.15.0 INFO 56634 started on port: 56634 
2025-03-05 20:50:18 5.15.0 INFO 56634 loaded CA X509 from path

  file:/Users/pavelrappo/.m2/repository/org/mock-server/mockserver-netty-no-dependencies/5.15.0/mockserver-netty-no-dependencies-5.15.0.jar!/org/mockserver/socket/CertificateAuthorityCertificate.pem

 containing PEM

  -----BEGIN CERTIFICATE-----
  MIIDqDCCApCgAwIBAgIEPhwe6TANBgkqhkiG9w0BAQsFADBiMRswGQYDVQQDDBJ3
  d3cubW9ja3NlcnZlci5jb20xEzARBgNVBAoMCk1vY2tTZXJ2ZXIxDzANBgNVBAcM
  BkxvbmRvbjEQMA4GA1UECAwHRW5nbGFuZDELMAkGA1UEBhMCVUswIBcNMTYwNjIw
  MTYzNDE0WhgPMjExNzA1MjcxNjM0MTRaMGIxGzAZBgNVBAMMEnd3dy5tb2Nrc2Vy
  dmVyLmNvbTETMBEGA1UECgwKTW9ja1NlcnZlcjEPMA0GA1UEBwwGTG9uZG9uMRAw
  DgYDVQQIDAdFbmdsYW5kMQswCQYDVQQGEwJVSzCCASIwDQYJKoZIhvcNAQEBBQAD
  ggEPADCCAQoCggEBAPGORrdkwTY1H1dvQPYaA+RpD+pSbsvHTtUSU6H7NQS2qu1p
  sE6TEG2fE+Vb0QIXkeH+jjKzcfzHGCpIU/0qQCu4RVycrIW4CCdXjl+T3L4C0I3R
  mIMciTig5qcAvY9P5bQAdWDkU36YGrCjGaX3QlndGxD9M974JdpVK4cqFyc6N4gA
  Onys3uS8MMmSHTjTFAgR/WFeJiciQnal+Zy4ZF2x66CdjN+hP8ch2yH/CBwrSBc0
  ZeH2flbYGgkh3PwKEqATqhVa+mft4dCrvqBwGhBTnzEGWK/qrl9xB4mTs4GQ/Z5E
  8rXzlvpKzVJbfDHfqVzgFw4fQFGV0XMLTKyvOX0CAwEAAaNkMGIwHQYDVR0OBBYE
  FH3W3sL4XRDM/VnRayaSamVLISndMA8GA1UdEwEB/wQFMAMBAf8wCwYDVR0PBAQD
  AgG2MCMGA1UdJQQcMBoGCCsGAQUFBwMBBggrBgEFBQcDAgYEVR0lADANBgkqhkiG
  9w0BAQsFAAOCAQEAecfgKuMxCBe/NxVqoc4kzacf9rjgz2houvXdZU2UDBY3hCs4
  MBbM7U9Oi/3nAoU1zsA8Rg2nBwc76T8kSsfG1TK3iJkfGIOVjcwOoIjy3Z8zLM2V
  YjYbOUyAQdO/s2uShAmzzjh9SV2NKtcNNdoE9e6udvwDV8s3NGMTUpY5d7BHYQqV
  sqaPGlsKi8dN+gdLcRbtQo29bY8EYR5QJm7QJFDI1njODEnrUjjMvWw2yjFlje59
  j/7LBRe2wfNmjXFYm5GqWft10UJ7Ypb3XYoGwcDac+IUvrgmgTHD+E3klV3SUi8i
  Gm5MBedhPkXrLWmwuoMJd7tzARRHHT6PBH/ZGw==
  -----END CERTIFICATE-----

 
2025-03-05 20:50:18 5.15.0 INFO 56634 loaded CA private key from path

  file:/Users/pavelrappo/.m2/repository/org/mock-server/mockserver-netty-no-dependencies/5.15.0/mockserver-netty-no-dependencies-5.15.0.jar!/org/mockserver/socket/PKCS8CertificateAuthorityPrivateKey.pem
 
2025-03-05 20:50:18 5.15.0 INFO received binary request:

  // screened
 
2025-03-05 20:50:18 5.15.0 INFO received binary request:

  // screened
 
2025-03-05 20:50:18 5.15.0 INFO loaded CA X509 from path

  file:/Users/pavelrappo/.m2/repository/org/mock-server/mockserver-netty-no-dependencies/5.15.0/mockserver-netty-no-dependencies-5.15.0.jar!/org/mockserver/socket/CertificateAuthorityCertificate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1TK3iJkfGIOVjcwOoIjy3Z8zLM2V
  YjYbOUyAQdO/s2uShAmzzjh9SV2NKtcNNdoE9e6udvwDV8s3NGMTUpY5d7BHYQqV
  sqaPGlsKi8dN+gdLcRbtQo29bY8EYR5QJm7QJFDI1njODEnrUjjMvWw2yjFlje59
  j/7LBRe2wfNmjXFYm5GqWft10UJ7Ypb3XYoGwcDac+IUvrgmgTHD+E3klV3SUi8i
  Gm5MBedhPkXrLWmwuoMJd7tzARRHHT6PBH/ZGw==
  -----END CERTIFICATE-----

 
2025-03-05 20:50:18 5.15.0 INFO loaded CA private key from path

  file:/Users/pavelrappo/.m2/repository/org/mock-server/mockserver-netty-no-dependencies/5.15.0/mockserver-netty-no-dependencies-5.15.0.jar!/org/mockserver/socket/PKCS8CertificateAuthorityPrivateKey.pem
 
2025-03-05 20:50:18 5.15.0 INFO 56634 returning binary response:

  // screened

 from:

  google.com/74.125.193.113:443

 for forwarded binary request:

  // screened
 
2025-03-05 20:50:18 5.15.0 INFO returning binary response:

  // screened
  
 from:

  google.com/74.125.193.113:443

 for forwarded binary request:

  // screened
 
2025-03-05 20:51:09 5.15.0 INFO 56634 stopped for port: 56634

Binary data // screened by me.

Workaround

Force a lower version of HTTP:

% time curl -k --http1.1 --proxy localhost:56520 https://google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="https://www.google.com/">here</A>.
</BODY></HTML>
curl -k --http1.1 --proxy localhost:56520 https://google.com  0.01s user 0.01s system 1% cpu 0.694 total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant