WireMock-Net / WireMock.Net

WireMock.Net is a flexible product for stubbing and mocking web HTTP responses using advanced request matching and response templating. Based on the functionality from http://WireMock.org, but extended with more functionality.
Apache License 2.0
1.35k stars 197 forks source link

Connection prematurely closed BEFORE response #1110

Closed sharlinsingh2812 closed 1 month ago

sharlinsingh2812 commented 1 month ago

I am getting the following error:
reactor.netty.http.client.PrematureCloseException: Connection prematurely closed BEFORE response when trying to get the _/_admin/mappings after composing up a docker container with the following image sheyenrath/wiremock.net-alpine:latest. (As of 22 May 2024, the latest was - 1.5.54)

The expected behavior is that a list of mappings should be returned.

Other information:

docker-compose.yaml

services:
  fake-service:
    image: sheyenrath/wiremock.net-alpine:latest
    container_name: fake-service
    volumes:
      - ./mappings.json:/app/__admin/mappings/mappings.json
    command: [
      "dotnet",
      "wiremock-net.dll",
      "--Urls", "http://*:80 http://*:9009",
      "--ReadStaticMappings", "true",
      "--WireMockLogger", "WireMockConsoleLogger",
      "--Port", "9009" ]
    healthcheck:
      test: [ "CMD-SHELL", "wget --spider -O /dev/null localhost:9009/healthz" ]
      interval: 5s
      start_period: 5s
    ports:
      - 9009:9009

GET request

GET /__admin/mappings HTTP/1.1
Host: localhost:9009
###

Response

GET http://localhost:9009/__admin/mappings

reactor.netty.http.client.PrematureCloseException: Connection prematurely closed BEFORE response
StefH commented 1 month ago

Tested on Windows 11

Starting your example works fine:

PS C:\Dev\GitHub\WireMock.Net-docker\Docker Compose Examples\Linux - Alpine 2> docker compose up
[+] Running 1/1
 ✔ Container fake-service  Recreated                                                                                                                                                                                                                   0.1s
Attaching to fake-service
fake-service  | 05/24/2024 08:57:32 [Info] : By Stef Heyenrath (https://github.com/WireMock-Net/WireMock.Net)
fake-service  | 05/24/2024 08:57:32 [Debug] : Server settings {
fake-service  |   "Port": 9009,
fake-service  |   "UseSSL": null,
fake-service  |   "HostingScheme": null,
fake-service  |   "UseHttp2": false,
fake-service  |   "StartAdminInterface": true,
fake-service  |   "ReadStaticMappings": true,
fake-service  |   "WatchStaticMappings": false,
fake-service  |   "WatchStaticMappingsInSubdirectories": false,
fake-service  |   "ProxyAndRecordSettings": null,
fake-service  |   "Urls": null,
fake-service  |   "StartTimeout": 10000,
fake-service  |   "AllowPartialMapping": false,
fake-service  |   "AdminUsername": null,
fake-service  |   "AdminPassword": null,
fake-service  |   "AdminAzureADTenant": null,
fake-service  |   "AdminAzureADAudience": null,
fake-service  |   "RequestLogExpirationDuration": null,
fake-service  |   "MaxRequestLogCount": null,
fake-service  |   "CorsPolicyOptions": 0,
fake-service  |   "AllowCSharpCodeMatcher": false,
fake-service  |   "AllowBodyForAllHttpMethods": false,
fake-service  |   "AllowOnlyDefinedHttpStatusCodeInResponse": false,
fake-service  |   "DisableJsonBodyParsing": false,
fake-service  |   "DisableRequestBodyDecompressing": false,
fake-service  |   "DisableDeserializeFormUrlEncoded": false,
fake-service  |   "HandleRequestsSynchronously": false,
fake-service  |   "CertificateSettings": null,
fake-service  |   "CustomCertificateDefined": false,
fake-service  |   "ClientCertificateMode": 0,
fake-service  |   "AcceptAnyClientCertificate": false,
fake-service  |   "WebhookSettings": null,
fake-service  |   "UseRegexExtended": true,
fake-service  |   "SaveUnmatchedRequests": false,
fake-service  |   "DoNotSaveDynamicResponseInLogEntry": false,
fake-service  |   "QueryParameterMultipleValueSupport": null,
fake-service  |   "ProtoDefinitions": null,
fake-service  |   "GraphQLSchemas": null
fake-service  | }
fake-service  | 05/24/2024 08:57:32 [Info] : Server using .NET 6.0
fake-service  | 05/24/2024 08:57:32 Press Ctrl+C to shut down
fake-service  | 05/24/2024 08:57:32 WireMock.Net server running

Calling Health Point works:

fake-service  | 05/24/2024 08:58:02 [DebugRequestResponse] : Admin[False] {
fake-service  |   "Guid": "2917092b-1407-46c6-9bcf-36c1291988fa",
fake-service  |   "Request": {
fake-service  |     "ClientIP": "::1",
fake-service  |     "DateTime": "2024-05-24T08:58:02.5466137Z",
fake-service  |     "Path": "/healthz",
fake-service  |     "AbsolutePath": "/healthz",
fake-service  |     "Url": "http://localhost:9009/healthz",
fake-service  |     "AbsoluteUrl": "http://localhost:9009/healthz",
fake-service  |     "ProxyUrl": null,
fake-service  |     "Query": {},
fake-service  |     "Method": "GET",
fake-service  |     "HttpVersion": "1.1",
fake-service  |     "Headers": {
fake-service  |       "Connection": [
fake-service  |         "close"
fake-service  |       ],
fake-service  |       "Host": [
fake-service  |         "localhost:9009"
fake-service  |       ],
fake-service  |       "User-Agent": [
fake-service  |         "Wget"
fake-service  |       ]
fake-service  |     },
fake-service  |     "Cookies": {},
fake-service  |     "Body": null,
fake-service  |     "BodyAsJson": null,
fake-service  |     "BodyAsBytes": null,
fake-service  |     "BodyEncoding": null,
fake-service  |     "DetectedBodyType": null,
fake-service  |     "DetectedBodyTypeFromContentType": null
fake-service  |   },
fake-service  |   "Response": {
fake-service  |     "StatusCode": 404,
fake-service  |     "Headers": {
fake-service  |       "Content-Type": [
fake-service  |         "application/json"
fake-service  |       ]
fake-service  |     },
fake-service  |     "BodyDestination": null,
fake-service  |     "Body": null,
fake-service  |     "BodyAsJson": {
fake-service  |       "Guid": null,
fake-service  |       "Status": "No matching mapping found",
fake-service  |       "Error": null
fake-service  |     },
fake-service  |     "BodyAsBytes": null,
fake-service  |     "BodyAsFile": null,
fake-service  |     "BodyAsFileIsCached": null,
fake-service  |     "BodyOriginal": null,
fake-service  |     "BodyEncoding": null,
fake-service  |     "DetectedBodyType": 2,
fake-service  |     "DetectedBodyTypeFromContentType": null,
fake-service  |     "FaultType": null,
fake-service  |     "FaultPercentage": null
fake-service  |   },
fake-service  |   "MappingGuid": null,
fake-service  |   "MappingTitle": null,
fake-service  |   "RequestMatchResult": null,
fake-service  |   "PartialMappingGuid": null,
fake-service  |   "PartialMappingTitle": null,
fake-service  |   "PartialRequestMatchResult": null
fake-service  | }
fake-service  | 05/24/2024 08:58:02 WireMock.Net server running

GET via Chrome works fine: image

sharlinsingh2812 commented 1 month ago

Thanks Stef Heyenrat

Looks like a newer/updated image for v1.5.54 was pushed to Docker Hub. (May 22, 2024). I was using the image v1.5.54 that was pushed on May 19,2024)

Not getting the issue anymore.

StefH commented 1 month ago

Fixed with this indeed:

1.5.55 (22 May 2024)