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

Server stops if contacted too early #54

Open
fdcds opened this issue Apr 8, 2020 · 0 comments
Open

Server stops if contacted too early #54

fdcds opened this issue Apr 8, 2020 · 0 comments

Comments

@fdcds
Copy link

fdcds commented Apr 8, 2020

I am using this script to start swagger-converter locally:

#!/bin/sh

port=6767

onexit() {
        podman stop "${ctid}"
}
trap onexit EXIT

ctid="$(podman run -d -p "${port}":8080 docker.io/swaggerapi/swagger-converter:v1.0.2@sha256:90a122587733a0b802e6c9a7cda33c35115c38694912cce4678c66dff312d6b1)"

# FIXME: swagger-converter stops when connected too early
sleep 5

while ! http --print= HEAD http://localhost:"${port}"/ ; do
        sleep 1
done

xdg-open http://localhost:"${port}"/

sleep infinity

If I remove the sleep 5, swagger-converter will stop the server immediately when receiving the first connection:

http: error: ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')) while doing HEAD request to URL: http://localhost:6767/

http: error: ConnectionError: HTTPConnectionPool(host='localhost', port=6767): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7fdcbbe9c810>: Failed to establish a new connection: [Errno 111] Connection refused')) while doing HEAD request to URL: http://localhost:6767/

http: error: ConnectionError: HTTPConnectionPool(host='localhost', port=6767): Max retries exceeded with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f63fb15e6d0>: Failed to establish a new connection: [Errno 111] Connection refused')) while doing HEAD request to URL: http://localhost:6767/

I would expect swagger-converter to gracefully handle also early connection attempts.

Pod logs:

2020-04-08 08:36:26.476:INFO::main: Logging initialized @122ms to org.eclipse.jetty.util.log.StdErrLog
2020-04-08 08:36:26.483:INFO:oejr.Runner:main: Runner
2020-04-08 08:36:26.630:INFO:oejs.Server:main: jetty-9.4.9.v20180320; built: 2018-03-20T12:21:10Z; git: 1f8159b1e4a42d3f79997021ea1609f2fbac6de5; jvm 1.8.0_212-b04
2020-04-08 08:36:27.513:INFO:oejs.session:main: DefaultSessionIdManager workerName=node0
2020-04-08 08:36:27.513:INFO:oejs.session:main: No SessionScavenger set, using defaults
2020-04-08 08:36:27.516:INFO:oejs.session:main: Scavenging every 600000ms
loading inflector config from inflector.yaml
08:36:28.160 [main] DEBUG io.swagger.v3.parser.OpenAPIV3Parser - Loaded raw data: ---
openapi: 3.0.0
info:
  title: Swagger Converter
  description: Converts a 1.x or 2.x Swagger definition to the OpenAPI 3.0.1 format
  version: 1.0.2
servers:
- url: "/"
paths:
  "/convert":
    get:
      tags:
      - Converter
      summary: Convert a swagger definition
      description: |
        Converts the supplied payload to a 3.0 specification
        based on a `url` parameter, which points to a older
        specification version
      operationId: convertByUrl
      parameters:
      - name: url
        in: query
        description: A URL to the swagger definition
        required: true
        schema:
          type: string
      responses:
        '200':
          description: successfully converted schema
          content:
            "application/json":
              schema:
                type: object
                properties: {}
            "application/yaml":
              schema:
                type: object
                properties: {}
        '400':
          description: 'invaild input schema, or could not be converted'
          content:
            "*/*":
              schema:
                type: array
                description: error messages
                items:
                  type: string
    post:
      tags:
      - Converter
      summary: Convert a swagger definition
      description: |
        Converts the supplied payload to a 3.0 specification
        based on an input specification
      operationId: convertByContent
      requestBody:
        description: the specification to convert
        content:
          "application/json":
            schema:
              type: object
              properties: {}
          "application/yaml":
            schema:
              type: object
              properties: {}
        required: true
      responses:
        '200':
          description: successfully converted schema
          content:
            "application/json":
              schema:
                type: object
                properties: {}
            "application/yaml":
              schema:
                type: object
                properties: {}
        '400':
          description: 'invaild input schema, or could not be converted'
          content:
            "*/*":
              schema:
                type: array
                description: error messages
                items:
                  type: string
components: {}
08:36:28.172 [main] DEBUG io.swagger.v3.parser.OpenAPIV3Parser - Parsed rootNode: {"openapi":"3.0.0","info":{"title":"Swagger Converter","description":"Converts a 1.x or 2.x Swagger definition to the OpenAPI 3.0.1 format","version":"1.0.2"},"servers":[{"url":"/"}],"paths":{"/convert":{"get":{"tags":["Converter"],"summary":"Convert a swagger definition","description":"Converts the supplied payload to a 3.0 specification\nbased on a `url` parameter, which points to a older\nspecification version\n","operationId":"convertByUrl","parameters":[{"name":"url","in":"query","description":"A URL to the swagger definition","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"successfully converted schema","content":{"application/json":{"schema":{"type":"object","properties":{}}},"application/yaml":{"schema":{"type":"object","properties":{}}}}},"400":{"description":"invaild input schema, or could not be converted","content":{"*/*":{"schema":{"type":"array","description":"error messages","items":{"type":"string"}}}}}}},"post":{"tags":["Converter"],"summary":"Convert a swagger definition","description":"Converts the supplied payload to a 3.0 specification\nbased on an input specification\n","operationId":"convertByContent","requestBody":{"description":"the specification to convert","content":{"application/json":{"schema":{"type":"object","properties":{}}},"application/yaml":{"schema":{"type":"object","properties":{}}}},"required":true},"responses":{"200":{"description":"successfully converted schema","content":{"application/json":{"schema":{"type":"object","properties":{}}},"application/yaml":{"schema":{"type":"object","properties":{}}}}},"400":{"description":"invaild input schema, or could not be converted","content":{"*/*":{"schema":{"type":"array","description":"error messages","items":{"type":"string"}}}}}}}}},"components":{}}
08:36:28.197 [main] DEBUG io.swagger.v3.parser.OpenAPIV3Parser - Loaded raw data: ---
openapi: 3.0.0
info:
  title: Swagger Converter
  description: Converts a 1.x or 2.x Swagger definition to the OpenAPI 3.0.1 format
  version: 1.0.2
servers:
- url: "/"
paths:
  "/convert":
    get:
      tags:
      - Converter
      summary: Convert a swagger definition
      description: |
        Converts the supplied payload to a 3.0 specification
        based on a `url` parameter, which points to a older
        specification version
      operationId: convertByUrl
      parameters:
      - name: url
        in: query
        description: A URL to the swagger definition
        required: true
        schema:
          type: string
      responses:
        '200':
          description: successfully converted schema
          content:
            "application/json":
              schema:
                type: object
                properties: {}
            "application/yaml":
              schema:
                type: object
                properties: {}
        '400':
          description: 'invaild input schema, or could not be converted'
          content:
            "*/*":
              schema:
                type: array
                description: error messages
                items:
                  type: string
    post:
      tags:
      - Converter
      summary: Convert a swagger definition
      description: |
        Converts the supplied payload to a 3.0 specification
        based on an input specification
      operationId: convertByContent
      requestBody:
        description: the specification to convert
        content:
          "application/json":
            schema:
              type: object
              properties: {}
          "application/yaml":
            schema:
              type: object
              properties: {}
        required: true
      responses:
        '200':
          description: successfully converted schema
          content:
            "application/json":
              schema:
                type: object
                properties: {}
            "application/yaml":
              schema:
                type: object
                properties: {}
        '400':
          description: 'invaild input schema, or could not be converted'
          content:
            "*/*":
              schema:
                type: array
                description: error messages
                items:
                  type: string
components: {}
08:36:28.201 [main] DEBUG io.swagger.v3.parser.OpenAPIV3Parser - Parsed rootNode: {"openapi":"3.0.0","info":{"title":"Swagger Converter","description":"Converts a 1.x or 2.x Swagger definition to the OpenAPI 3.0.1 format","version":"1.0.2"},"servers":[{"url":"/"}],"paths":{"/convert":{"get":{"tags":["Converter"],"summary":"Convert a swagger definition","description":"Converts the supplied payload to a 3.0 specification\nbased on a `url` parameter, which points to a older\nspecification version\n","operationId":"convertByUrl","parameters":[{"name":"url","in":"query","description":"A URL to the swagger definition","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"successfully converted schema","content":{"application/json":{"schema":{"type":"object","properties":{}}},"application/yaml":{"schema":{"type":"object","properties":{}}}}},"400":{"description":"invaild input schema, or could not be converted","content":{"*/*":{"schema":{"type":"array","description":"error messages","items":{"type":"string"}}}}}}},"post":{"tags":["Converter"],"summary":"Convert a swagger definition","description":"Converts the supplied payload to a 3.0 specification\nbased on an input specification\n","operationId":"convertByContent","requestBody":{"description":"the specification to convert","content":{"application/json":{"schema":{"type":"object","properties":{}}},"application/yaml":{"schema":{"type":"object","properties":{}}}},"required":true},"responses":{"200":{"description":"successfully converted schema","content":{"application/json":{"schema":{"type":"object","properties":{}}},"application/yaml":{"schema":{"type":"object","properties":{}}}}},"400":{"description":"invaild input schema, or could not be converted","content":{"*/*":{"schema":{"type":"array","description":"error messages","items":{"type":"string"}}}}}}}}},"components":{}}
08:36:28.205 [main] DEBUG i.s.oas.inflector.OpenAPIInflector - adding operation for `/convert` GET
08:36:28.210 [main] WARN  i.s.o.i.utils.ReflectionUtils - Failed to find class [io.swagger.handler.Converter]
08:36:28.212 [main] INFO  i.s.o.i.c.OpenAPIOperationController - looking for method: `public ResponseContext convertByUrl(io.swagger.oas.inflector.models.RequestContext request, String [simple type, class java.lang.String])` in class `io.swagger.handler.ConverterController`
08:36:28.213 [main] DEBUG i.s.o.i.c.OpenAPIOperationController - found class `io.swagger.handler.ConverterController`
08:36:28.215 [main] DEBUG i.s.oas.inflector.OpenAPIInflector - adding operation for `/convert` POST
08:36:28.215 [main] WARN  i.s.o.i.utils.ReflectionUtils - Failed to find class [io.swagger.handler.Converter]
08:36:28.216 [main] INFO  i.s.o.i.c.OpenAPIOperationController - looking for method: `public ResponseContext convertByContent(io.swagger.oas.inflector.models.RequestContext request, com.fasterxml.jackson.databind.JsonNode [simple type, class com.fasterxml.jackson.databind.JsonNode])` in class `io.swagger.handler.ConverterController`
08:36:28.216 [main] DEBUG i.s.o.i.c.OpenAPIOperationController - found class `io.swagger.handler.ConverterController`
08:36:28.238 [main] WARN  i.s.o.i.utils.ReflectionUtils - Failed to find class [io.swagger.handler.Converter]
08:36:28.238 [main] INFO  i.s.o.i.c.OpenAPIOperationController - looking for method: `public ResponseContext convertByContent(io.swagger.oas.inflector.models.RequestContext request, com.fasterxml.jackson.databind.JsonNode [simple type, class com.fasterxml.jackson.databind.JsonNode])` in class `io.swagger.handler.ConverterController`
08:36:28.238 [main] DEBUG i.s.o.i.c.OpenAPIOperationController - found class `io.swagger.handler.ConverterController`
2020-04-08 08:36:28.498:INFO:oejsh.ContextHandler:main: Started o.e.j.w.WebAppContext@33a10788{/,file:///tmp/jetty-0.0.0.0-8080-server.war-_-any-8582308719230484926.dir/webapp/,AVAILABLE}{file:///swagger-converter/server.war}
2020-04-08 08:36:28.510:INFO:oejs.AbstractConnector:main: Started ServerConnector@433ffad1{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
2020-04-08 08:36:28.511:INFO:oejs.Server:main: Started @2162ms
2020-04-08 08:36:54.169:INFO:oejs.AbstractConnector:Thread-0: Stopped ServerConnector@433ffad1{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
2020-04-08 08:36:54.170:INFO:oejs.session:Thread-0: Stopped scavenging
2020-04-08 08:36:54.186:INFO:oejsh.ContextHandler:Thread-0: Stopped o.e.j.w.WebAppContext@33a10788{/,null,UNAVAILABLE}{file:///swagger-converter/server.war}
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