On 1/29/2015 11:08 PM, Praveen Pvs wrote:
On Thu, Jan 29, 2015 at 9:57 PM, Ray Satiro via curl-library <[email protected] <mailto:[email protected]>> wrote:

    On 1/29/2015 4:32 AM, Praveen Pvs wrote:

        Is there way to just check the connection status of server? I
        need to know the connection status of the server before
        posting the actual data. If connection with server is
        available, then post the data to the server otherwise dont post.

        I have written the following function to check the connection:
        All the required parameters are set to the curl handler before
        passing to this function


    What do you mean by the connection status? From your client to the
    server or from the server to some backend? If you just want to see
    if the server is up I think a fast way would be HEAD or OPTIONS.
    Neither is going to work in every single case. I don't think there
    is a generic catch all.


I am trying to check the connection status from my client to the server. I am sending following HEAD request to determine that.

HEAD /MYCOM/ HTTP/1.1
Host: 10.8.225.10:26030 <http://10.8.225.10:26030>
Accept: */*
Content-Type:text/xml



        I am testing this function with various servers to which i
        need to post the data. one server was returning CURLE_OK for
        curl_easy_perform function and CURLINFO_RESPONSE_CODE as 200
        (which i considered as success), but one more server was
        returning 22(CURLE_HTTP_RETURNED_ERROR) for curl_easy_perform
        function and CURLINFO_RESPONSE_CODE as 404.


    So for connection status currently you are retrieving target page
    on servers and get a 200? And in the case of one server you get
    404 and it's not. It sounds like your program is doing what you
    intended, no?


When I sent above HEAD request to two servers. One of them returned CURLINFO_RESPONSE_CODE as 200 and another one as 404. But both the servers are up and running. So i am not sure how to determine that connection to server is available.

All 404 means is resource /MYCOM/ is not available in response to your request at the time that request is processed. Why it's not available is something you'll have to figure out. Maybe it doesn't exist temporarily or permanently. Maybe it's available in some other case, like for some other method. 404 sometimes comes with an explanation for why the resource is not available. For a better understanding see [1] and [2]. Watch out for so called "soft 404" responses.

        Could you please help me to make it generic to test the
        connection status of the server?


    I doubt it but someone may come up with something if you give more
    detail.

Problem statement: My client program should able to determine whether the connection is available to the server before posting the actual data. client would like to know that it is able to connect to server before posting the actual data.

That is not enough information. Also we are going outside the scope of the mailing list now. You are determining connection status based on the availability of the /MYCOM/ resource. In either case you have made a successful connection to the server however I suspect what your client wants is to determine if some resource is available before continuing. For example:

client <-> frontend server <-> backend server
client doesn't want to waste time or bandwidth when backend which handles target resource is down

You would need to work to discover some resource you could use to test that condition. You need some baselines. It's possible you may not be able to determine availability of the target resource without getting it or even as a last resort posting to it. For the latter you could try for an innocuous (think this through) test post with little or no content so you don't waste bandwidth, and timeout if it's an issue where the frontend server hangs without a backend. Finally, it's possible there may be no way to determine the availability of the target resource without posting the actual data.


[1]: https://tools.ietf.org/html/rfc7231#section-6.5.4
[2]: http://en.wikipedia.org/wiki/HTTP_404

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to