duplicate response on Connetor timeout
by Balu S
Hello,
I have found that if the HTTPConnector times out without receiving the
response from the backend API, then somewhere down the line it generates 2
error responses and this is evident from the metrics as it show 2 failures
as supposed to 1 failure for the single request.
So there are 2 issues,
- firstly the returned error response contains 2 error XMLs appended to
each other and sent to the browser and hence not a valid XML.
- The metrics also shows as 2 failure response for single request.
I have been looking the sources but without the way to debug within running
application, it quite hard to follow the flow.
This can be easily simulated with setting very low timeouts (2 secs for ex)
in apiman.properties.
apiman-gateway.connector-factory.http.timeouts.read=2
apiman-gateway.connector-factory.http.timeouts.write=2
Could you please look at the issue and also If you could guide me how to
setup debugging environment, then I can try to fix that as well.
regards
Balu
7 years, 12 months
APIMAN configuration for high-load application
by Ram.Tanna@ril.com
Dear Team,
We are using APIMAN in our application which would have 40k concurrent requests.
There would be around 7000 requests/second. Out of which 2500 requests are for uploading and downloading a file with payload size of 512 KB/request. Other request will have payload of 50 to 80 KB.
Folks who are using apiman in their system, can please share your experience.
What would be the best configuration for such high-load application ?
Thanks and Regards,
Ram Tanna
"Confidentiality Warning: This message and any attachments are intended only for the use of the intended recipient(s).
are confidential and may be privileged. If you are not the intended recipient. you are hereby notified that any
review. re-transmission. conversion to hard copy. copying. circulation or other use of this message and any attachments is
strictly prohibited. If you are not the intended recipient. please notify the sender immediately by return email.
and delete this message and any attachments from your system.
Virus Warning: Although the company has taken reasonable precautions to ensure no viruses are present in this email.
The company cannot accept responsibility for any loss or damage arising from the use of this email or attachment."
8 years
version migration
by Balu S
Hello,
I would like to move to 1.2.10/1.2.9 version from 1.2.8 version in the
existing wildfly installation. As I have already configured organizations,
API and ClientApps in existing installation and want to keep it safe from
being overwritten.
I can think of following options for migration, but not sure this would
work.
option 1:
- Export the apiman data
- unzip the 1.2.10 overlay zip
- Import the data using admin user
option 2:
- replace only the wars taken from overlay zip to the wildfly /deployment
directory
Does unzip apiman overlay overwrites the configuration data ? What is the
ideal way ? Could you please advise ?
regards
Balu
8 years
Re: [Apiman-user] Logger exception
by Marc Savy
I'll try to look into it shortly and post back onto the ML.
On 30 January 2017 at 16:16, Balu S <sbalu27(a)gmail.com> wrote:
> Hi Marc,
> thanks for your quick response. Unfortunately it doesn't work.
>
> Although, what I am trying to achieve is to use "Slf4jLoggerFactory" and
> it fails with same null pointer.
>
> 2017-01-30 17:12:59,911 ERROR [org.jboss.msc.service.fail] (ServerService
> Thread Pool -- 64) MSC000001: Failed to start service
> jboss.undertow.deployment.default-server.default-host./apiman-gateway:
> org.jboss.msc.service.StartException in service jboss.undertow.deployment.
> default-server.default-host./apiman-gateway: java.lang.RuntimeException:
> java.lang.RuntimeException: java.lang.NullPointerException
> at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.
> run(UndertowDeploymentService.java:85)
> at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> at java.util.concurrent.ThreadPoolExecutor.runWorker(
> ThreadPoolExecutor.java:1142)
> at java.util.concurrent.ThreadPoolExecutor$Worker.run(
> ThreadPoolExecutor.java:617)
> at java.lang.Thread.run(Thread.java:745)
> at org.jboss.threads.JBossThread.run(JBossThread.java:320)
> Caused by: java.lang.RuntimeException: java.lang.RuntimeException:
> java.lang.NullPointerException
> at io.undertow.servlet.core.DeploymentManagerImpl.deploy(
> DeploymentManagerImpl.java:236)
> at org.wildfly.extension.undertow.deployment.UndertowDeploymentService.
> startContext(UndertowDeploymentService.java:100)
> at org.wildfly.extension.undertow.deployment.UndertowDeploymentService$1.
> run(UndertowDeploymentService.java:82)
> ... 6 more
> Caused by: java.lang.RuntimeException: java.lang.NullPointerException
> at io.apiman.gateway.engine.impl.ConfigDrivenEngineFactory.instantiate(
> ConfigDrivenEngineFactory.java:179)
> at io.apiman.gateway.engine.impl.ConfigDrivenEngineFactory.create(
> ConfigDrivenEngineFactory.java:163)
> at io.apiman.gateway.engine.impl.ConfigDrivenEngineFactory.
> createLoggerFactory(ConfigDrivenEngineFactory.java:152)
> at io.apiman.gateway.engine.impl.AbstractEngineFactory.createEngine(
> AbstractEngineFactory.java:60)
> at io.apiman.gateway.platforms.war.WarGateway.init(WarGateway.java:55)
> at io.apiman.gateway.platforms.war.listeners.WarGatewayBootstrapper.
> contextInitialized(WarGatewayBootstrapper.java:
>
> On Mon, Jan 30, 2017 at 5:07 PM, Marc Savy <marc.savy(a)redhat.com> wrote:
>
>> I think you want
>> io.apiman.common.logging.DefaultDelegateFactory in that field rather
>> than SystemOutLogger directly.
>>
>> Does that work?
>>
>> The name is probably confusing - it *was* the default one at some point.
>>
>>
>>
>> On 30 January 2017 at 15:57, Balu S <sbalu27(a)gmail.com> wrote:
>>
>>> Hello,
>>>
>>> I'm trying to simply replace the NoOpLoggerFactory to SystemOutLogger in
>>> apiman.properties and get below exception. It is quite strange as
>>> SystemOutLogger is infact implements IDelegateFactory.
>>>
>>> #apiman-gateway.logger-factory=io.apiman.common.logging.impl
>>> .NoOpLoggerFactory
>>> apiman-gateway.logger-factory=io.apiman.common.logging.impl.
>>> SystemOutLogger
>>>
>>> Also, If I try to change to Slf4jLoggerFactory, then even
>>> the Slf4jLoggerFactory.class is not found.
>>>
>>> Could you please advise if there is any reference to be added and causes
>>> below error. Thanks
>>>
>>> . Falling back to the Default. [No IDataEncrypter class configured.]
>>> 16:50:52,028 ERROR [org.jboss.msc.service.fail] (ServerService Thread
>>> Pool -- 69) MSC000001: Failed
>>> to start service jboss.undertow.deployment.defa
>>> ult-server.default-host./apiman-gateway-api: org.jbos
>>> s.msc.service.StartException in service jboss.undertow.deployment.defa
>>> ult-server.default-host./apima
>>> n-gateway-api: java.lang.RuntimeException: java.lang.ClassCastException:
>>> io.apiman.common.logging.impl.SystemOutLogger cannot be cast to
>>> io.apiman.common.logging.IDelegateFactory
>>> at org.wildfly.extension.undertow.deployment.UndertowDeployment
>>> Service$1.run(UndertowDeploym
>>> entService.java:85)
>>> at java.util.concurrent.Executors$RunnableAdapter.call(Executor
>>> s.java:511)
>>> at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>>> at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPool
>>> Executor.java:1142)
>>> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoo
>>> lExecutor.java:617)
>>> at java.lang.Thread.run(Thread.java:745)
>>> at org.jboss.threads.JBossThread.run(JBossThread.java:320)
>>> Caused by: java.lang.RuntimeException: java.lang.ClassCastException:
>>> io.apiman.common.logging.impl.SystemOutLogger cannot be cast to
>>> io.apiman.common.logging.IDelegateFactory
>>> at io.undertow.servlet.core.DeploymentManagerImpl.deploy(Deploy
>>> mentManagerImpl.java:236)
>>> at org.wildfly.extension.undertow.deployment.UndertowDeployment
>>> Service.startContext(Undertow
>>> DeploymentService.java:100)
>>> at org.wildfly.extension.undertow.deployment.UndertowDeployment
>>> Service$1.run(UndertowDeploym
>>>
>>>
>>> regards
>>> Balu
>>>
>>> _______________________________________________
>>> Apiman-user mailing list
>>> Apiman-user(a)lists.jboss.org
>>> https://lists.jboss.org/mailman/listinfo/apiman-user
>>>
>>>
>>
>
8 years
APIMAN Best Practice for Response Critical APIs
by Manvendra.Rai@ril.com
Hello All,
We are using APIMAN for very response time critical APIs like - Upload API for uploading picture, videos etc.. to AWS S3. We don't want to upload files directly to S3 as there are few custom authentication & auth(via Redis In-Memory DB/Cache) checks we perform via our custom plugins in APIMAN. While, our APIs run OK without APIMAN, we see response time degrading considerably with APIMAN. What could be some of the best practices we should follow for performance tuning?
We tried WildFly & Tomcat, though latter comparatively performed better, overall response time didn't improve much.
Thanks,
Manav
"Confidentiality Warning: This message and any attachments are intended only for the use of the intended recipient(s).
are confidential and may be privileged. If you are not the intended recipient. you are hereby notified that any
review. re-transmission. conversion to hard copy. copying. circulation or other use of this message and any attachments is
strictly prohibited. If you are not the intended recipient. please notify the sender immediately by return email.
and delete this message and any attachments from your system.
Virus Warning: Although the company has taken reasonable precautions to ensure no viruses are present in this email.
The company cannot accept responsibility for any loss or damage arising from the use of this email or attachment."
8 years
Re: [Apiman-user] API policy response data handler
by Balu S
Thanks for your inputs.
Yes, I mean HTTP error codes (non-200) that are returned to client. For
example, when a request is missing query parameters and the API responds
with a "Bad request" (400) along with error XML. Here the error code is set
at HTTP level only and Apiman metrics should consider it as bad response
(in my opinion). Neither I do not see the Apiman source (HttpApiConnection)
interpreting the HTTP response using the HTTP code. But with the custom
policy, If I check for non-200 code and handle as failure, then metrics
shows them as error.
To clarify on my implementation with custom policy, I'm not trying to
change the HTTP error code based on the response, rather we are unpacking
the error response body and packing in different XML format as done by
Apiman. Is this not a valid scenario ? I think there could other scenarios
where one want to alter the response body. I agree there will be additional
cost to performance and memory, but can it be not done one demand basis
like how one can implement IDataPolicy to parse the response only if he
needs to.
Thanks
Balu
On Thu, Feb 2, 2017 at 10:31 PM, Eric Wittmann <eric.wittmann(a)redhat.com>
wrote:
> The bottom line here is that you cannot return a Policy Failure (or
> customize it) based on information in the response body. The response is
> streamed from the back-end to the client, and at the time streaming begins,
> the response code and HTTP headers have already been sent.
>
> It sounds to me like you're asking for a feature where you can parse the
> response body *before* the policy's "apply" method is invoked. We have
> such a feature for requests, but not for responses. I suspect core changes
> to apiman would be required to enable that. It seems like a reasonable
> request to me, as long as users of the feature understand the performance
> and memory requirements of enabling it.
>
> -Eric
>
>
> On Thu, Feb 2, 2017 at 1:03 PM, Marc Savy <marc.savy(a)redhat.com> wrote:
>
>> NB: This is distinct from the body you're setting which contains a
>> JSON/XML payload containing the error code. It's in the HTTP protocol
>> itself.
>>
>> On 2 February 2017 at 18:02, Marc Savy <marc.savy(a)redhat.com> wrote:
>>
>>> That sounds like metrics are going wrong, or perhaps you're
>>> misinterpreting it (adding Eric).
>>>
>>> When you say your API returns an error, does it still return an
>>> appropriate non-200 error code at the HTTP level? For instance, 500 or
>>> similar? That's very important.
>>>
>>> There's a difference between an error and a failure - have you checked
>>> both of those fields to see whether they contain the information you're
>>> expecting to see.
>>>
>>> Certainly in my experience we *do* collect the metrics you're talking
>>> about, unless I'm misunderstanding you.
>>>
>>> On 2 February 2017 at 17:40, Balu S <sbalu27(a)gmail.com> wrote:
>>>
>>>> Hi Marc,
>>>>
>>>> I shall explain my use case. From our API call, we return error
>>>> response (in XML or JSON) for 401, 500 and so on. However, Apiman metrics
>>>> seems to just consider them as good response (it is, as Apiman received the
>>>> response back) and show as successful response. So I have made custom
>>>> policy to intercept the response to know if it is failure and trigger the
>>>> Policy Failure. This is fairly simple and straight forward as the response
>>>> code will just do the purpose. But I want also to add some additional
>>>> information about the failure to Policy Failure. This additional
>>>> information is in the original error response which will be lost once
>>>> doFailure() happens. And no we don't want to those additional information
>>>> in some HTTP headers to pass around. Hence I implemented responseHandler()
>>>> to handle the response buffer and like you pointed out, it seems to be too
>>>> late to meddle the response.
>>>>
>>>> So ideally, there are possible 2 solution
>>>>
>>>> - Apiman metrics can interpret the response as unsuccessful for such
>>>> error response from API call.
>>>> - Handle the response buffer data before the write() call to
>>>> response outputstream.
>>>>
>>>> Do you see any alternative solution?
>>>>
>>>> Thanks
>>>> Balu
>>>>
>>>> On Thu, Feb 2, 2017 at 6:15 PM, Marc Savy <marc.savy(a)redhat.com> wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> Perhaps URLRewritingPolicy https://github.com/apiman/apim
>>>>> an/blob/master/gateway/engine/policies/src/main/java/io/apim
>>>>> an/gateway/engine/policies/URLRewritingPolicy.java be an informative
>>>>> place to start?
>>>>>
>>>>> - Apiman streams data, so the client may be receiving data already by
>>>>> the time you've determined you want to cancel (the connection is already
>>>>> established; headers have been sent) - it's often too late to gracefully
>>>>> cancel. You could try throwing an exception and seeing what happens (not
>>>>> recommended practice!).
>>>>>
>>>>> If that doesn't work, perhaps you can explain your use-case more
>>>>> clearly and explicitly so we can see what the alternatives are?
>>>>>
>>>>> - Policies are *static* instances, if you are assigning that buffer to
>>>>> the object then it's as if you were writing "static Buffer buffer" and
>>>>> different requests will all share that variable (and thus swap it out
>>>>> repeatedly!).
>>>>>
>>>>> Regards,
>>>>> Marc
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On 2 February 2017 at 16:56, Balu S <sbalu27(a)gmail.com> wrote:
>>>>>
>>>>>> Hello,
>>>>>> I'm trying to parse the response using responseDataHandler() in the
>>>>>> custom policy. In cases, if the response from API is of certain content, I
>>>>>> would like the Apiman to consider as failure. But I don't find a way to
>>>>>> throw policy failure from responseDataHandler(). And I cannot achieve this
>>>>>> in doApply() as the ApiResponse object does not have "content" to parse.
>>>>>>
>>>>>> Also, what I found is write(chunk) in the AbstractStream is called
>>>>>> after doApply, so I cannot set any attributes in it to fetch it in
>>>>>> doApply() and trigger doFailure().
>>>>>>
>>>>>> For example, in below call, how to throw as policy failure after
>>>>>> parsing the contents ? Or how can I access response content even before
>>>>>> write() method.
>>>>>>
>>>>>>
>>>>>> *URLRewritingPolicy.java*
>>>>>>
>>>>>> @Override
>>>>>> protected IReadWriteStream<ApiResponse>
>>>>>> responseDataHandler(ApiResponse response,
>>>>>> IPolicyContext context, URLRewritingConfig
>>>>>> policyConfiguration) {
>>>>>> if (policyConfiguration.isProcessResponseBody()) {
>>>>>> return new URLRewritingStream(context.get
>>>>>> Component(IBufferFactoryComponent.class), response,
>>>>>> policyConfiguration.getFromRegex(),
>>>>>> policyConfiguration.getToReplacement());
>>>>>> } else {
>>>>>> return null;
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> *URLRewritingStream.java*
>>>>>>
>>>>>> /**
>>>>>> * @see io.apiman.gateway.engine.io.AbstractStream#write(io.
>>>>>> apiman.gateway.engine.io.IApimanBuffer)
>>>>>> */
>>>>>> @Override
>>>>>> public void write(IApimanBuffer chunk) {
>>>>>> if (buffer == null) {
>>>>>> buffer = bufferFactory.cloneBuffer(chunk);
>>>>>> } else {
>>>>>> buffer.append(chunk);
>>>>>> }
>>>>>> atEnd = false;
>>>>>> processBuffer();
>>>>>> }
>>>>>>
>>>>>>
>>>>>> Best regards
>>>>>> Balu
>>>>>>
>>>>>> _______________________________________________
>>>>>> Apiman-user mailing list
>>>>>> Apiman-user(a)lists.jboss.org
>>>>>> https://lists.jboss.org/mailman/listinfo/apiman-user
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>
8 years
How to change the URL location with URL Rewriting Policy
by Celso Agra
All,
I'm trying to change the location path in browser with my nodeJS
application.
For some reason, the apiman does not allow me to change that.
So, I'm think to use the URL Rewriting Policy Configuration, but I'd like
to understand how it works.
Here's my nodeJS code:
req.url = config.redirect_site;
res.statusCode = 302;
res.location(config.redirect_site);
res.end();
Without APIman it works fine! Does anyone know how can I set a different
url with this policy or any other method in Apiman?
Thanks!
Best regards,
--
---
*Celso Agra*
8 years
API policy response data handler
by Balu S
Hello,
I'm trying to parse the response using responseDataHandler() in the custom
policy. In cases, if the response from API is of certain content, I would
like the Apiman to consider as failure. But I don't find a way to throw
policy failure from responseDataHandler(). And I cannot achieve this in
doApply() as the ApiResponse object does not have "content" to parse.
Also, what I found is write(chunk) in the AbstractStream is called after
doApply, so I cannot set any attributes in it to fetch it in doApply() and
trigger doFailure().
For example, in below call, how to throw as policy failure after parsing
the contents ? Or how can I access response content even before write()
method.
*URLRewritingPolicy.java*
@Override
protected IReadWriteStream<ApiResponse> responseDataHandler(ApiResponse
response,
IPolicyContext context, URLRewritingConfig policyConfiguration)
{
if (policyConfiguration.isProcessResponseBody()) {
return new
URLRewritingStream(context.getComponent(IBufferFactoryComponent.class),
response,
policyConfiguration.getFromRegex(),
policyConfiguration.getToReplacement());
} else {
return null;
}
}
*URLRewritingStream.java*
/**
* @see
io.apiman.gateway.engine.io.AbstractStream#write(io.apiman.gateway.engine.io.IApimanBuffer)
*/
@Override
public void write(IApimanBuffer chunk) {
if (buffer == null) {
buffer = bufferFactory.cloneBuffer(chunk);
} else {
buffer.append(chunk);
}
atEnd = false;
processBuffer();
}
Best regards
Balu
8 years
How to limit access for IP Address
by Celso Agra
All,
I'd like to know if the Apiman has policies to restrict the number of
access from specific IP Address. Such as Quota Policy or Rate Limiting
Policy.
Should I have to implement this Policy?
Best Regards,
--
---
*Celso Agra*
8 years