Closed ipirva closed 6 years ago
Did you define an apikey plan ?
Yes, I did - I published the plan and subscribed to it. I am exporting the API configuration:
{
"name": "Rek Event Token API",
"version": "1.0",
"description": "Rek Event Token API",
"visibility": "PRIVATE",
"tags": [],
"labels": [],
"proxy": {
"context_path": "/event/token",
"strip_context_path": false,
"loggingMode": "NONE",
"groups": [
{
"name": "default-group",
"endpoints": [
{
"name": "default",
"target": "http://eventapi_nginx/event/token/",
"weight": 1,
"backup": false,
"type": "HTTP",
"http": {
"connectTimeout": 5000,
"idleTimeout": 60000,
"keepAlive": true,
"readTimeout": 10000,
"pipelining": true,
"maxConcurrentConnections": 100,
"useCompression": true,
"followRedirects": false
},
"proxy": {
"enabled": false,
"host": "null",
"port": 0,
"type": "HTTP"
},
"ssl": {
"enabled": false,
"trustAll": false,
"hostnameVerifier": false,
"pem": "null"
}
}
],
"load_balancing": {
"type": "ROUND_ROBIN"
}
}
]
},
"paths": {
"/": []
},
"services": {
"discovery": {
"enabled": false
}
},
"resources": [],
"path_mappings": [],
"members": [
{
"username": "admin",
"role": "PRIMARY_OWNER"
}
],
"pages": [],
"plans": [
{
"id": "311c3d03-4895-4d54-9c3d-034895fd549c",
"name": "Plan Rek Event Token API",
"description": "Plan Rek Event Token API",
"validation": "MANUAL",
"security": "API_KEY",
"type": "API",
"status": "PUBLISHED",
"apis": [
"3823d974-9a1a-4713-a3d9-749a1a071320"
],
"order": 1,
"characteristics": [],
"created_at": 1533828595756,
"updated_at": 1533828650198,
"published_at": 1533828650198,
"paths": {
"/": []
}
}
]
}
Actually if I use a wrong API Key, I do receive a HTTPS Status 403. But if I use the right one, I get the HTTP Status 500, as described above:
:~$ curl -H "X-Gravitee-API-Key: f67606aa-0b68-4d91-b3aa-d5ec19618989" https://gravitee-gw.local.home/event/token/ -k
{
"message" : "API Key is not valid or is expired / revoked.",
"http_status_code" : 403
}
:~$ curl -H "X-Gravitee-API-Key: 83408c6b-755b-466b-827e-d8c6410a87d6" https://gravitee-gw.local.home/event/token/ -k
-- no output ---
:~$ curl -H "X-Gravitee-API-Key: 83408c6b-755b-466b-827e-d8c6410a87d6" https://gravitee-gw.local.home.p2o.be/event/token/ -k -v
* Connection state changed (MAX_CONCURRENT_STREAMS updated)!
< HTTP/2 500
< x-gravitee-transaction-id: d4545681-82ca-4502-9456-8182ca15024d
< content-length: 0
< date: Fri, 10 Aug 2018 14:27:58 GMT
<
* Curl_http_done: called premature == 0
I did a clear for the Gravitee Gateway container logs and took the logs generated when curl with the right key:
14:30:34.568 [vert.x-eventloop-thread-0] [] ERROR i.g.g.policy.impl.RequestPolicyChain - Unexpected error while running policy io.gravitee.gateway.policy.impl.PolicyImpl@75c3de91
io.gravitee.gateway.policy.PolicyChainException: io.gravitee.gateway.policy.PolicyException: java.lang.reflect.InvocationTargetException
at io.gravitee.gateway.policy.impl.RequestPolicyChain.execute(RequestPolicyChain.java:46)
at io.gravitee.gateway.policy.impl.PolicyChain.doNext(PolicyChain.java:66)
at io.gravitee.gateway.policy.impl.StreamablePolicyChain.doNext(StreamablePolicyChain.java:51)
at io.gravitee.gateway.policy.impl.RequestPolicyChainProcessor.execute(RequestPolicyChainProcessor.java:63)
at io.gravitee.gateway.handlers.api.ApiReactorHandler.handleClientRequest(ApiReactorHandler.java:178)
at io.gravitee.gateway.handlers.api.ApiReactorHandler.doHandle(ApiReactorHandler.java:130)
at io.gravitee.gateway.reactor.handler.AbstractReactorHandler.handle(AbstractReactorHandler.java:75)
at io.gravitee.gateway.reactor.impl.DefaultReactor.lambda$route$0(DefaultReactor.java:81)
at io.gravitee.gateway.reactor.handler.transaction.TransactionHandler.handle(TransactionHandler.java:57)
at io.gravitee.gateway.reactor.handler.transaction.TransactionHandler.handle(TransactionHandler.java:28)
at io.gravitee.gateway.reactor.impl.DefaultReactor.route(DefaultReactor.java:92)
at io.gravitee.gateway.standalone.vertx.VertxReactorHandler.handle(VertxReactorHandler.java:37)
at io.gravitee.gateway.standalone.vertx.VertxReactorHandler.handle(VertxReactorHandler.java:27)
at io.vertx.core.http.impl.Http1xServerConnection.processMessage(Http1xServerConnection.java:454)
at io.vertx.core.http.impl.Http1xServerConnection.handleMessage(Http1xServerConnection.java:144)
at io.vertx.core.http.impl.Http1xServerHandler.handleMessage(Http1xServerHandler.java:74)
at io.vertx.core.http.impl.Http1xServerHandler.handleMessage(Http1xServerHandler.java:35)
at io.vertx.core.net.impl.VertxHandler.lambda$channelRead$1(VertxHandler.java:146)
at io.vertx.core.impl.ContextImpl.lambda$wrapTask$2(ContextImpl.java:337)
at io.vertx.core.impl.ContextImpl.executeFromIO(ContextImpl.java:195)
at io.vertx.core.net.impl.VertxHandler.channelRead(VertxHandler.java:144)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.vertx.core.http.impl.HttpServerImpl$Http2UpgradeHandler.channelRead(HttpServerImpl.java:970)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.channel.ChannelInboundHandlerAdapter.channelRead(ChannelInboundHandlerAdapter.java:86)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:111)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:310)
at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:284)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.vertx.core.http.impl.Http1xOrH2CHandler.end(Http1xOrH2CHandler.java:61)
at io.vertx.core.http.impl.Http1xOrH2CHandler.channelRead(Http1xOrH2CHandler.java:38)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:340)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1359)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:362)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:348)
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:935)
at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:141)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:645)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:580)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:497)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:459)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
Caused by: io.gravitee.gateway.policy.PolicyException: java.lang.reflect.InvocationTargetException
at io.gravitee.gateway.policy.impl.PolicyImpl.invoke(PolicyImpl.java:91)
at io.gravitee.gateway.policy.impl.PolicyImpl.onRequest(PolicyImpl.java:44)
at io.gravitee.gateway.policy.impl.RequestPolicyChain.execute(RequestPolicyChain.java:44)
... 58 common frames omitted
Caused by: java.lang.reflect.InvocationTargetException: null
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at io.gravitee.gateway.policy.impl.PolicyImpl.invoke(PolicyImpl.java:89)
... 60 common frames omitted
Caused by: java.lang.NullPointerException: no null host accepted
at java.util.Objects.requireNonNull(Objects.java:228)
at io.vertx.core.http.impl.HttpClientImpl.createRequest(HttpClientImpl.java:999)
at io.vertx.core.http.impl.HttpClientImpl.createRequest(HttpClientImpl.java:993)
at io.vertx.core.http.impl.HttpClientImpl.request(HttpClientImpl.java:519)
at io.gravitee.gateway.http.client.vertx.VertxHttpClient.request(VertxHttpClient.java:119)
at io.gravitee.gateway.core.invoker.DefaultInvoker.invoke(DefaultInvoker.java:89)
at io.gravitee.gateway.handlers.api.ApiReactorHandler.lambda$handleClientRequest$6(ApiReactorHandler.java:160)
at io.gravitee.gateway.policy.impl.RequestPolicyChainProcessor.execute(RequestPolicyChainProcessor.java:65)
at io.gravitee.gateway.policy.impl.RequestPolicyChainProcessor.lambda$execute$0(RequestPolicyChainProcessor.java:57)
at io.gravitee.gateway.policy.NoOpPolicyChain.doNext(NoOpPolicyChain.java:41)
at io.gravitee.gateway.policy.impl.RequestPolicyChainProcessor.execute(RequestPolicyChainProcessor.java:63)
at io.gravitee.gateway.policy.impl.RequestPolicyChainProcessor.lambda$execute$0(RequestPolicyChainProcessor.java:57)
at io.gravitee.gateway.policy.NoOpPolicyChain.doNext(NoOpPolicyChain.java:41)
at io.gravitee.gateway.policy.impl.RequestPolicyChainProcessor.execute(RequestPolicyChainProcessor.java:63)
at io.gravitee.gateway.policy.impl.RequestPolicyChainProcessor.lambda$execute$0(RequestPolicyChainProcessor.java:57)
at io.gravitee.gateway.policy.impl.PolicyChain.doNext(PolicyChain.java:76)
at io.gravitee.gateway.policy.impl.StreamablePolicyChain.doNext(StreamablePolicyChain.java:51)
at io.gravitee.policy.apikey.ApiKeyPolicy.onRequest(ApiKeyPolicy.java:94)
... 65 common frames omitted
I tried two actions: configuring a Plan Keyless and the second one, reinitialising the installed Gravitee component (restarting the containers and trashing the elasticsearch and mongodb data). The errors are still persisting. I will keep looking.
Can you provide us a json export of your API definition ?
There is one here above, from 4 days ago. Please find one I tested recently with a Keyless Plan.
{
"name": "Rek Event Token API",
"version": "1.0",
"description": "Rek Event Token API",
"visibility": "PRIVATE",
"tags": [],
"labels": [],
"proxy": {
"context_path": "/event/token",
"strip_context_path": false,
"loggingMode": "NONE",
"groups": [
{
"name": "default-group",
"endpoints": [
{
"name": "default",
"target": "http://eventapi_nginx/event/token",
"weight": 1,
"backup": false,
"type": "HTTP",
"http": {
"connectTimeout": 5000,
"idleTimeout": 60000,
"keepAlive": true,
"readTimeout": 10000,
"pipelining": true,
"maxConcurrentConnections": 100,
"useCompression": true,
"followRedirects": false
}
}
],
"load_balancing": {
"type": "ROUND_ROBIN"
}
}
]
},
"paths": {
"/": []
},
"services": {
"discovery": {
"enabled": false
}
},
"resources": [],
"path_mappings": [],
"members": [
{
"username": "admin",
"role": "PRIMARY_OWNER"
}
],
"pages": [],
"plans": [
{
"id": "4289ce3b-3b93-48f1-89ce-3b3b93a8f1a2",
"name": "Plan Rek Event Token API - Keyless",
"description": "Plan Rek Event Token API - Keyless",
"validation": "AUTO",
"security": "KEY_LESS",
"securityDefinition": "{}",
"type": "API",
"status": "PUBLISHED",
"apis": [
"f775cfee-7ac1-4b53-b5cf-ee7ac13b537c"
],
"order": 1,
"characteristics": [],
"created_at": 1534100507445,
"updated_at": 1534100513216,
"published_at": 1534100513216,
"paths": {
"/": []
},
"excluded_groups": []
}
]
}
Ok sorry, I missed it.
So, the issue is simply because of the host name for your endpoint. The underscore is not understood by the URL in Java. This will be fixed in the next version of gravitee.io (1.19).
If you want to go ahead, I would advice you to change the underscore with a '-' in your hostname.
I am sorry David, I did not want to make it sound like a reproach. Thank you very much for your support, it was indeed because of the "_".
Don't be sorry, I did not consider it as a reproach!
Expected Behavior
I have NGINX Backend API servers sharing a dedicated network with the Gravitee Gateway. The Gravitee Gateway container is attached to 2 networks:
one shared with the other Gravitee containers and with Traefik
eventapi_nginx: (my Backend API) image: nginx --- CUT for brevity --- networks:
gravitee-gateway: image: graviteeio/gateway:latest --- CUT for brevity --- networks:
I would expect Gravitee Gateway to communicate with the Endpoint over the shared network.
Current Behavior
I test with curl and I target the Gravitee Gateway DNS name - Gavitee Gateway receives the traffic, but returns HTTP Status 500 - as per Curl and the UI info
The HTTPS is terminated by Traefik.
I can see some errors in Gravitee Gateway Container:
I do not see any errors on the other Gravitee containers.
There is no traffic reaching the Backend API Endpoint (tcpdump).
The setup was previously validated having all the containers on the same network and using Traefik as entrypoint for all the HTTP traffic. In this case I used for the backend API endpoint a global DNS name sending towards the docker Host server IP.
Your Environment
I am using the latest Gravitee containers' versions and I am spawning everything using docker compose.