apache / apisix

The Cloud-Native API Gateway
https://apisix.apache.org/blog/
Apache License 2.0
14.35k stars 2.49k forks source link

apisix integrates java plug-in help #10355

Open githubxubin opened 11 months ago

githubxubin commented 11 months ago

Description

I am using apsix, I developed a simple plug-in in the java language, tested well locally, and when it came time to deploy, it did not deploy properly: Reference: https://github.com/tzssangglass/java-plugin-runner-demo-1

my apisix route config:

{
    "id": "483159253050196671",
    "create_time": 1697514956,
    "update_time": 1697538848,
    "uri": "/*",
    "name": "java-plugin-demo",
    "priority": 1,
    "methods": [
        "GET",
        "POST"
    ],
    "plugins": {
        "ext-plugin-pre-req": {
            "conf": [
                {
                    "name": "TokenValidator",
                    "value": "{\"validate_header\":\"token\",\"validate_url\":\"https://www.sso.foo.com/token/validate\",\"rejected_code\":\"401\"}"
                }
            ]
        }
    },
    "upstream": {
        "nodes": [
            {
                "host": "192.168.97.25",
                "port": 1004,
                "weight": 1
            }
        ],
        "retries": 1,
        "timeout": {
            "connect": 6,
            "send": 6,
            "read": 6
        },
        "type": "roundrobin",
        "scheme": "http",
        "discovery_args": {
            "group_name": "",
            "namespace_id": ""
        },
        "pass_host": "pass",
        "keepalive_pool": {
            "idle_timeout": 60,
            "requests": 1000,
            "size": 320
        }
    },
    "labels": {
        "API_VERSION": "x"
    },
    "status": 1
}

my apisix config:

apisix:
  node_listen: 9080              # APISIX listening port
  enable_ipv6: false
#  ssl:
#    enable: true
#    enable_http2: true
#    listen_port: 9443
#    ssl_protocols: "TLSv1 TLSv1.1 TLSv1.2 TLSv1.3"
#    ssl_trusted_certificate: /usr/local/apisix/conf/cert/apig.ca-bundle

  allow_admin:                  # http://nginx.org/en/docs/http/ngx_http_access_module.html#allow
    - 0.0.0.0/0              # We need to restrict ip access rules for security. 0.0.0.0/0 is for test.

  admin_key:
    - name: "admin"
      key: edd1c9f034335f136f87ad84b625c8f1
      role: admin                 # admin: manage all configuration data
                                  # viewer: only can view configuration data
    - name: "viewer"
      key: 4054f7cf07e344346cd3f287985e76a2
      role: viewer

  enable_control: true
  control:
    ip: "0.0.0.0"
    port: 9092

etcd:
  host:                           # it's possible to define multiple etcd hosts addresses of the same etcd cluster.
    - "http://10.210.21.106:2379"     # multiple etcd address
  prefix: "/apisix"               # apisix configurations prefix
  timeout: 30                     # 30 seconds

nginx_config:                     # config for render the template to generate nginx.conf
  error_log: logs/error.log
  error_log_level:  warn   
  worker_processes: auto          # if you want use multiple cores in container, you can inject the number of cpu as environment variable "APISIX_WORKER_PROCESSES"
  http_configuration_snippet: |
    lua_ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
  http_server_location_configuration_snippet: |
    proxy_ssl_protocols TLSv1.2 TLSv1.3;

ext-plugin:
  path_for_test: /tmp/runner.sock
  cmd: ['java', '-jar', '-Xmx1g', '-Xms1g', '/usr/local/apisix/demo-0.0.1-SNAPSHOT.jar']

plugins:
  - basic-auth
  - jwt-auth
  - key-auth
  - cors
  - ip-restriction
  - public-api
  - limit-req
  - limit-conn
  - redirect
  - echo
  - limit-count
  - uri-blocker
  - csrf
  - referer-restriction
  - traffic-split 
  - kafka-logger
  - ext-plugin-post-req
  - ext-plugin-req-req
  - ext-plugin-post-resp

the error log:

2023/10/18 07:24:28 [warn] 51#51: *108 [lua] init.lua:931: respawning new runner..., context: ngx.timer
2023/10/18 07:24:28 [error] 51#123: lua pipe child execvp() failed while executing java (2: No such file or directory)
2023/10/18 07:24:28 [warn] 51#51: *108 [lua] init.lua:919: runner exited with reason: exit, status: 1, context: ngx.timer
2023/10/18 07:24:28 [warn] 51#51: *108 [lua] init.lua:361: flush_token(): flush conf token in shared dict, context: ngx.timer
2023/10/18 07:24:28 [warn] 51#51: *108 [lua] init.lua:818: flush conf token lrucache, context: ngx.timer
2023/10/18 07:24:28 [warn] 51#51: *108 [lua] init.lua:929: respawn runner 3 seconds later with cmd: ["java","-jar","-Xmx1g","-Xms1g","\/usr\/local\/apisix\/demo-0.0.1-SNAPSHOT.jar"], context: ngx.timer
2023/10/18 07:24:28 [warn] 49#49: *7329 [lua] init.lua:361: flush_token(): flush conf token in shared dict, context: ngx.timer
2023/10/18 07:24:28 [warn] 49#49: *7329 [lua] init.lua:818: flush conf token lrucache, context: ngx.timer
2023/10/18 07:24:28 [warn] 50#50: *7330 [lua] init.lua:361: flush_token(): flush conf token in shared dict, context: ngx.timer
2023/10/18 07:24:28 [warn] 50#50: *7330 [lua] init.lua:818: flush conf token lrucache, context: ngx.timer
2023/10/18 07:24:28 [warn] 48#48: *7331 [lua] init.lua:361: flush_token(): flush conf token in shared dict, context: ngx.timer
2023/10/18 07:24:28 [warn] 48#48: *7331 [lua] init.lua:818: flush conf token lrucache, context: ngx.timer
2023/10/18 07:24:28 [warn] 47#47: *7332 [lua] init.lua:361: flush_token(): flush conf token in shared dict, context: ngx.timer
2023/10/18 07:24:28 [warn] 47#47: *7332 [lua] init.lua:818: flush conf token lrucache, context: ngx.timer

What's the problem, please

Environment

githubxubin commented 11 months ago

Now there are new problems: image

2023/10/18 10:02:00 [error] 51#51: *1852 [lua] init.lua:155: failed to fetch registryconnection refused, context: ngx.timer
monkeyDluffy6017 commented 9 months ago

@githubxubin have you solved your problem?