Thanks!! that was all it took... moving that 1 line to within the 
function... not sure why the data event was being handled just fine the 
other way though...

but it's working so thanks again!!

On Wednesday, January 23, 2013 3:45:51 AM UTC-5, greelgorke wrote:
>
> put your oa.get call in your recursive function, then you can call 
> recursive function in on "close" handler, this should work. a retry request 
> is just another request, at least in http.
>
> Am Mittwoch, 23. Januar 2013 03:11:02 UTC+1 schrieb am_p1:
>>
>> Node and js noobie here so if there's a simple fix for this... I admit 
>> my humiliation in advance...
>>
>> I'm receiving millions of xml packets a day using node to pull from a 
>> streaming api and it's working great using less than 1% of my server!!
>>
>> But about 0 to 2 times a day "response end" followed by "response close" 
>> gets called and then, no more data. Not sure why but I assume it's 
>> something outside my server and beyond my control.
>>
>> Problem is how do I end the request from the "response close" callback 
>> and then retry the request to get it going again? I've tried request.abort, 
>> end, destroy, return and other things i've forgotten right now... but nada, 
>> I can't seem to end the request from within the "response close" callback.
>>
>> I might have made this more complicated trying to recursively call the 
>> function... which works great on another node, but it's a request/response 
>> type with a setTimeout, not streaming like this one.
>>
>> Anyway, the code's below and all I want to do after getting "response 
>> close" is to retry the request and get back to receiving the xml packets as 
>> fast as possible... like maybe with this:
>> setTimeout(recursive,100)
>>
>> Thanks for the help!!
>>
>>
>> ================================================================================
>> var oa = new 
>> oauth.OAuth(null,null,config.consumer_key,config.consumer_secret,"1.0",null,"HMAC-SHA1")
>>
>> var db = new odbc.Database()
>>
>> var request = 
>> oa.get(config.api_url+'?symbols='+syms,config.access_token,config.access_secret)
>>
>> var recursive = function () {
>>
>>   request.on('response',function(response) {
>>
>>     response.on('data',function(data) {
>>
>>       // ... lots o code, all working great
>>
>>       })
>>
>>     response.on('end',function() {
>>
>>       console.log(chld,'response end',Date(),microtime.now())
>>
>>       })
>>
>>     response.on('close',function() {
>>
>>       console.log(chld,'response close',Date(),microtime.now())
>>
>>       // i have tried various code here but nada - function never ends 
>> (at least, i think thats whats happening)
>>
>>       })
>>
>>     })
>>
>>   // the 4 below have never fired
>>
>>   request.on('socket',function() {
>>
>>     console.log(chld,'request socket',Date(),microtime.now())
>>
>>     })
>>
>>   request.on('connect',function() {
>>
>>     console.log(chld,'request connect',Date(),microtime.now())
>>
>>     })
>>
>>   request.on('upgrade',function() {
>>
>>     console.log(chld,'request upgrade',Date(),microtime.now())
>>
>>     })
>>
>>   request.on('continue',function() {
>>
>>     console.log(chld,'request continue',Date(),microtime.now())
>>
>>     })
>>
>>   request.end()
>>
>>   // also tried code here but nada
>>
>> }
>>
>> db.open("DRIVER={DB2};DATABASE=......",function(err) {
>>
>>   if(err) {
>>     console.log(chld,err)
>>     db.close(function() {
>>     })
>>
>>   } else {  
>>
>>     recursive()
>>
>>   }
>>
>> })
>>
>

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to