HTTP health monitor

Hi All, I am trying to configure HTTP health monitoring using two target servers. The issue i am facing is when i configure maxFailures i get 503 error code and once i remove it the proxy works fine. Any help on this would be appreciated. Thanks.

My config:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TargetEndpoint name="default">
    <Description/>
    <PreFlow name="PreFlow">
        <Request/>
        <Response/>
    </PreFlow>
    <Flows/>
    <PostFlow name="PostFlow">
        <Request/>
        <Response/>
    </PostFlow>
    <HTTPTargetConnection>
        <Properties/>
        <LoadBalancer>
            <Algorithm>Weighted</Algorithm>
            <Server name="target1">
                <Weight>1</Weight>
            </Server>
            <Server name="target2">
                <Weight>1</Weight>
            </Server>
            <MaxFailures>2</MaxFailures>
            <ServerUnhealthyResponse>
                <ResponseCode>500</ResponseCode>
                <ResponseCode>502</ResponseCode>
                <ResponseCode>503</ResponseCode>
                <ResponseCode>504</ResponseCode>
            </ServerUnhealthyResponse>
        </LoadBalancer>
        <Path>/a***/f*****/d****</Path>
       <HealthMonitor>
            <IsEnabled>true</IsEnabled>
            <IntervalInSec>3</IntervalInSec>
            <HTTPMonitor>
                <Request>
                    <ConnectTimeoutInSec>10</ConnectTimeoutInSec>
                    <SocketReadTimeoutInSec>30</SocketReadTimeoutInSec>
                    <Verb>GET</Verb>
                    <Path>/webservice/status</Path>
                </Request>
                <SuccessResponse>
                    <ResponseCode>200</ResponseCode>
                </SuccessResponse>
            </HTTPMonitor>
        </HealthMonitor>
    </HTTPTargetConnection>
</TargetEndpoint>
Solved Solved
0 19 931
1 ACCEPTED SOLUTION

Not applicable

I think you missed the port in the HTTP Monitor. Can you add port and test?

<Port>{value}</Port>

View solution in original post

19 REPLIES 19

Not applicable

I think you missed the port in the HTTP Monitor. Can you add port and test?

<Port>{value}</Port>

Yes It worked Priyadarshi. Thank you so much for your Help.

you are welcome.

Hi Priyadarshi, I added port number and when i access the proxy first few requests are 200 and after which i get { "fault": { "faultstring": "The Service is temporarily unavailable", "detail": { "errorcode": "messaging.adaptors.http.flow.NoActiveTargets" } } }. The requests are not routed to active target server. In my case the target server 2 is down and target server 1 is active.

This seems hitting to the target 2. As per document the http monitor should revert back to 1 when 2 is failing. But before any modification please undeploy and redeploy. If that works, we will have to configure http monitor in a better way.

Hi Priyadarshi, sometimes it works when i undeploy and deploy. What are other better ways to implement the http monitor?

If you see the document, it says it should be automatically come back if health monitoring is added. But still it's not coming back without restart.

Can you try the same with TCP monitor as well?

Hi Priyadashi, I tried with TCP monitor it is working in the sense the requests are routed to server 1 and server 2 as well. Actually the server 2 is down. So i get success result for 2 requests and then next two requests would be 504 as the server 2 is down and this cycle goes on.

It shouldnt route the traffic to server 2 at all right, if its not able to get a response

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TargetEndpoint name="default">
    <Description/>
    <PreFlow name="PreFlow">
        <Request/>
        <Response/>
    </PreFlow>
    <Flows/>
    <PostFlow name="PostFlow">
        <Request/>
        <Response/>
    </PostFlow>
    <HTTPTargetConnection>
        <Properties/>
        <LoadBalancer>
            <Algorithm>Weighted</Algorithm>
            <Server name="server 1">
                <Weight>1</Weight>
            </Server>
            <Server name="server 2">
                <Weight>1</Weight>
            </Server>
            <MaxFailures>1</MaxFailures>
            <ServerUnhealthyResponse>
                <ResponseCode>500</ResponseCode>
                <ResponseCode>502</ResponseCode>
                <ResponseCode>503</ResponseCode>
                <ResponseCode>504</ResponseCode>
            </ServerUnhealthyResponse>
        </LoadBalancer>
        <Path>api/path</Path>
        <HealthMonitor>
            <IsEnabled>true</IsEnabled>
            <IntervalInSec>1</IntervalInSec>
            <TCPMonitor>
                <ConnectTimeoutInSec>1</ConnectTimeoutInSec>
            </TCPMonitor>
        </HealthMonitor>
    </HTTPTargetConnection>
</TargetEndpoint>

Not applicable
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TargetEndpoint name="default">
    <PreFlow name="PreFlow">
        <Request/>
        <Response/>
    </PreFlow>
    <Flows/>
    <PostFlow name="PostFlow">
        <Request/>
        <Response/>
    </PostFlow>
    <HTTPTargetConnection>
        <LoadBalancer>
            <Server name="test1"/>
            <Server name="echo"/>
            <MaxFailures>2</MaxFailures>
        </LoadBalancer>
        <Path>/v0/hello</Path>
        <HealthMonitor>
            <IsEnabled>true</IsEnabled>
            <IntervalInSec>1</IntervalInSec>
            <HTTPMonitor>
                <Request>
                    <ConnectTimeoutInSec>1</ConnectTimeoutInSec>
                    <SocketReadTimeoutInSec>2</SocketReadTimeoutInSec>
                    <Port>80</Port>
                    <Verb>GET</Verb>
                    <Path>/v0/hello</Path>
                </Request>
                <SuccessResponse>
                    <ResponseCode>200</ResponseCode>
                </SuccessResponse>
            </HTTPMonitor>
        </HealthMonitor>
    </HTTPTargetConnection>
</TargetEndpoint>

This is the code that I implemented and tested in my account and this works as expected. It also automatically comes back to flow when the health check gets success.

Hi Priyadarshi, the above configuration looks similar to mine except for the path. For my application the base path and the path specified inside the health monitor are different. Would that cause an issue?

base-path : host/api/v1/***

health-monitor: host/web**/status

It should not be. Please try to replicate as I had shared with interval and all attributes.

I tried the way you mentioned, gave both the paths as same, but still i am getting 503. When i investigate the logs it keeps going to the second host. which is unavailable

But TCP monitor is working fine now.

Response code may be not matching. You have to take care of that. The response code should be matching and the number of times within a particular time. Then it will work for http.

Thanks priyadarshi. I will check on that. Could you tell me if there is anyway to include response body under <SuccessResponse>.

Can you try Payload tag inside success response. I didn't test it. Hope this works.

ok, let me try that.