Bug 980320 - node.js: Cannot read property 'getsockname' of undefined
node.js: Cannot read property 'getsockname' of undefined
Product: OpenShift Online
Classification: Red Hat
Component: Containers (Show other bugs)
Unspecified Unspecified
low Severity low
: ---
: ---
Assigned To: Hiro Asari
libra bugs
: Reopened
Depends On:
  Show dependency treegraph
Reported: 2013-07-02 00:58 EDT by Ilkkah
Modified: 2015-05-14 19:22 EDT (History)
3 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2013-10-26 18:14:01 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Ilkkah 2013-07-02 00:58:32 EDT
Description of problem:
The site in question: http://dtest1-ile.rhcloud.com/
I made a Node bug report too: https://github.com/joyent/node/issues/5774

At Node 0.10.11 (the latest code seems to be similar) I get this:

    if (port && handle.getsockname && port != handle.getsockname().port) {
TypeError: Cannot read property 'getsockname' of undefined
    at net.js:1071:23
    at Object.1:1 (cluster.js:587:5)
    at handleResponse (cluster.js:171:41)
    at respond (cluster.js:192:5)
    at handleMessage (cluster.js:202:5)
    at process.EventEmitter.emit (events.js:117:20)
    at handleMessage (child_process.js:318:10)
    at Pipe.channel.onread (child_process.js:345:11)

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. run "node server.js" at http://dtest1-ile.rhcloud.com/

Actual results:

Expected results:
Should run

Additional info:

Is there something in OpenShift's net/socket handling that I should know?
Comment 1 Mrunal Patel 2013-07-02 11:45:37 EDT
Looks like handle itself is undefined. Are you able to reproduce the issue with some simple test code?
Comment 2 Ilkkah 2013-07-02 20:43:18 EDT
The handle is indeed undefined. The lack of error handling is Node's fault.

But why the handle cannot be obtained is something that OpenShift may be partly responsible with, that's why I made this bug report.

The code itself is pretty complicated. I'm not sure I could simplify it, but I could see what I can do in the future if needed.

Comment 3 Hiro Asari 2013-07-02 21:58:33 EDT
Without the intimate knowledge of the application code, it is near impossible to figure out why `handle` is not defined. (We don't have access to your gear on http://dtest1-ile.rhcloud.com/)

https://github.com/joyent/node/issues/5330 may be relevant here, since it refers to approximately the same line in the same file (net.js). This issue is presumably fixed in 10.11, but maybe there are still issues to be resolved.

My best bet is to pursue it upstream with the node team.

The information given so far does not indicate that there is something that we can change to make your application go. Simplifying your application to isolate the problematic parts of your application and/or node.js would be most helpful, I think.
Comment 4 Hiro Asari 2013-09-12 11:40:11 EDT
Hello, have you had a chance to investigate this?

We need a simple reproduction to go any further.
Comment 5 Hiro Asari 2013-10-22 16:06:12 EDT
I'm closing this. If there is something else we can try to investigate this further, do let us know.
Comment 6 Ilkkah 2013-10-22 19:23:56 EDT

Sorry I didn't get back.

I just tried with the latest node, 0.10.21, but it still happens. 

I think it would take quite a bit of time to debug this further. If there is anyone at RedHat who wants to take a look, I could give all the access needed. But otherwise I think I will just delete the application.

Comment 7 Hiro Asari 2013-10-23 10:38:19 EDT
Hi there.

The best bet is to have a simple reproduction. Can you strip sensitive information of your application while retaining the problem?

As I said earlier, it is very difficult to guess what might be causing the problem.
Comment 8 Ilkkah 2013-10-23 12:55:37 EDT

The app in question is a Derby app (http://derbyjs.com/) and it's the default app that derby creates when starting a new project (command: derby new). So it doesn't contain any sensitive information.

If you have time to inspect this, please go ahead, you can have the access to it, if you need a public key placed there, you can do it or I can do it for you. 

The app itself is both very minimal and also quite large - the Derby framework is large, but the default app created is not. So it's hard to strip down. If it is needed to strip down, then I think it should be done component-by-component: for example creating an express app, and then adding components into it one-by-one and seeing when the problem happens.

I would think though that it is possible to debug the cause without stripping the app. It may even be easy, but it would require some debugging for sure.
Comment 9 Hiro Asari 2013-10-23 16:24:52 EDT
https://github.com/codeparty/derby/issues/263#issuecomment-18290683 and ensuing comments lead me to believe that you'll need to bind your application to the correct host and port for OpenShift. For Node.js, they will be OPENSHIFT_NODEJS_IP and OPENSHIFT_NODEJS_PORT. (See, for example: https://github.com/openshift-quickstart/nodejs-example/blob/master/server.js#L6-L7)

See http://openshift.github.io/documentation/oo_cartridge_guide.html#nodejs for further information.
Comment 10 Ilkkah 2013-10-26 18:14:01 EDT
That really seemed to be the problem. I'm very sorry to bother you this much with this, when it was mainly my fault. 

BTW, a side note: on some other Node hosting service the IP address binding isn't needed. So on OpenShift this is an extra step. Actually, Derby right now listens just the 'default ip', i.e. doesn't provide any IP address, but just the port. So, what it does is:
   server.listen(port, callback);

... and no hostname/ip address.

So this may limit options on OpenShift if IP address is required. 

This meant as a "fyi" and constructive information.

I'll close this issue. Thanks.

Note You need to log in before you can comment on or make changes to this bug.