It's connecting to localhost, so I don't think it's DNS. It's using a 
pre-existing TCP connection through HTTP keep-alive, so it's not the TCP 
connection overhead.

I'm totally drawing a blank...

At the moment it is running inside node-webkit, so I'm trying to figure out 
what's the best way to debug this...


On Monday, July 8, 2013 12:00:54 AM UTC-4, Rusty Conover wrote:
>
> I'd guess it is the delay of hostname resolution via DNS, combined with 
> any delay with establishing the tcp connection.
>
> On linux run "strace node foo.js" to see the system calls that are 
> happening.  Or tcpdump on the applicable network adaptor.
>
> Rusty
>
>
> On Sunday, July 7, 2013 10:43:15 AM UTC-4, Seung Chan Lim wrote:
>>
>> Also posted on: 
>> http://stackoverflow.com/questions/17509959/unknown-delay-for-socket-event-in-node-js-http-module
>>
>>
>> I am noticing an unexplainable(for now) delay between 
>> http.request().end() and when the 'socket' event fires.
>>
>> req = this.__http.request({hostname: host
>>                , port: port
>>                , path: path
>>                , method: method
>>                , headers : headers
>>                , agent: this._agent
>>            });
>> req.setNoDelay(true)
>> req.setSocketKeepAlive(true, 0);
>>
>> req.on("socket", _onSocket);
>> req.end()
>>
>> I'm using a single connection between client and server, and also using 
>> keep-alive throughagentkeepalive<https://github.com/TBEDP/agentkeepalive>. 
>> This is a local app connecting to a local CouchDB server, and maintaining a 
>> single persistent connection to it.
>>
>> this._agent = new this.__agentkeepalive({
>>     minSockets: 1
>>     ,maxSockets: 1
>>     , maxKeepAliveRequests: 0
>>     , maxKeepAliveTime: 300000});
>>
>> I have confirmed that the same exact socket is being reused for each 
>> request (i.e. by checking that the localPort is identical on each request), 
>> meaning that the connection is indeed persistent throughout the life of the 
>> app.
>>
>> But from time to time there's a delay of around 100 - 400ms between the 
>> req.end() call and when the 'socket' event fires and calls _onSocket. When 
>> there is no such delay, it takes around 10ms for the 'socket' event to fire.
>>
>> It doesn't happen all the time, it only happens sometimes, and I don't 
>> see any obvious pattern...
>>
>> Can anyone with a bit more intimate knowledge of how node.js HTTP is 
>> implemented tell me what happens between request.end() and the 'socket' 
>> event? What could possibly be the source of such a huge delay?
>>
>> thanks
>>
>

-- 
-- 
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

--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to