http.OnRequest()

I have been running this for several months and recently I am getting some additional data sent out that crashes my receiver?

You can see from the text there may be a problem, but where it is and how to fix it?

HTTP/1.1 204 No Content
Access-Control-Allow-Origin: *
Content-length: 15
Date: Fri, 31 Jan 2014 12:59:37 GMT
X-Imp-RequestID: OhAkjYa0XD6POnl8TynYMg
Connection: Close

I am ignoring this message now, but still curious as to why the server has started to error like this?

As in, you’re hitting the agent and getting a 204 reply? Is it getting to your agent at all, and how often are you hitting the URL?

Hugo, found some more info on what seems to be going on. When my http.onRequest() handler responds with anything other that a 200 status. I never receive any response. If I respond with 200 status I always receive a response?

`/---------------------------------------------------------
function requestHandler( request, response )
//---------------------------------------------------------
{
//
try {
//
response.header( “Access-Control-Allow-Origin”, “*” );

    if ( request.body == "0" ) {
        //
        server.log( "flushing data, now!" );
        //
        data.empty();
        //
        response.send( 204,"Data Flushed!" );            
    } else {
        //
        if ( request.body == "1" ) {

            //
            server.log("sending data" );
            //
            if ( data.length() == 0 ) {
                // There must be a problem so lets return an error condition.
                response.send( 204, "Check MagicEye!" );
                //
            } else {
                //
                local encode = http.base64encode( data.myblob );
                //
                data.empty();
                //
                response.send( 200, encode );
            }
        } else {
            //
            throw( "Unknown action!" );
        }
    }
}
//
catch( ex ) {
    //
    response.send( 500, "Internal Server Error: " + ex );
}

};`

The 200 status and the 500 status are returned without problem but I never get a response from the 204?

Hmm, 204 codes arent surpose to have a content other than headers, have you tried with no message ?

@mora, thanks but if you just send a send(204,"") I get nothing on the receiver!

Interesting. Will file a bug.

@nigelibrown - I just tried to repro this issue, and couldn’t. Could you clarify something a bit.

When you say you get nothing on the receiver, do you mean you don’t get a response back from the agent (ie - it eventually times out), or that there is no content in the response?

Could you please copy + paste the result of the cURL command you’re issuing with the verbose flag set:

`curl -d “1” --verbose https://agent.electricimp.com/YOUR_AGENT_ID