Reading Target server timeout value.

Hi,

I have configured the Target server and am reading its backend time with the below code

var startTime = context.getVariable('target.sent.start.timestamp');

var endTime = context.getVariable('target.received.end.timestamp');

This code works when the backend returns a response.

However, in timeout scenarios, the above code doesn't work and returns 0 value.

Is there a way to capture the timeout value when using target servers.

Thanks & Best regards,

Amit

0 10 407
10 REPLIES 10

Not applicable

Incase of timeout, the message processor closes the connection abnormally, so the above scenario does give 0.

If you will wait after the mp timeout time the connection will be closed.

Hi @Priyadarshi
Thanks for the reply.
However the timeout is configured to 5 secs for the backend.
Which is very less than the MP timeout set value. So the bckend connection is timing out before the MP timeout value.

Ok got it. Can you check the nginx log and see what it is showing?

Hi!

Actually we are using public cloud. No nginx.

The question is is there a possible way to get the time the flow spends with the backend without additional JS timelogs using built in variables.

If target server/loadbalancer is used (target not hardcoded in target endpoint) the targer.sent/target.recieved variables are null in case of socket timeout.

you can use logging in postcleint flow and test.

I have not tested, but logically it should be going to logging system.

The problem is not with the logging. I need the time how long the flow spends dealing with the backend request. Even if it is a waiting and then timeout.

Yes, that you can get with calculation. What you can do is increase the time out value in the proxy to a big amount, like 10secs. Then your api will wait until the timeout happens from the backend side.

Hope you got me.

Thanks Priyadarshi for your helping attitude!

Let me explain the error scenario in details.
Generally we calculate the time the flow spends dealing with the backend request reading the two mentioned variables.

var startTargetTime = context.getVariable('target.sent.start.timestamp');
var endTargetTime = context.getVariable('target.received.end.timestamp');
var backendTime = endTargetTime - startTargetTime;

This is working fine but when the backend server doesn't reply within timeout time.
The connection established, the backend request packages sent to the backend completely but the response from the backend server lasts too long hence timeout occurs (no matter how long is set).
I'm expecting at least the variable 'target.sent.start.timestamp' to be available but in this scenario it is null.
(btw in scenario when the backend host not available at all everything is working as expected, the timestamp variables are filled correctly)

I thought about a workaround to consider the configured timeout value as backend time in this case but that configuration also not available to read from code.

This issue observed since we changed from hardcoded target to using target servers.

Not applicable

Got. there is one more option you can try.

you can test configuring the backend in a service callout policy.

you also can use javascript policy to hit the backend directly using code.

That may help you.

I got the information from the support that this is a known issue and they will release the fix soon.