0

I have a NodeJS/Express/Jade app that works fine in my local Linux environment (Ubuntu 12.04 Desktop running NodeJS, talking to Ubuntu 12.04 Server running Couchbase). I have attempted to manually deploy the NodeJS app to a fresh Ubuntu 12.04 Server AMI on EC2. My Security Groups are set. The VM firewalls are set and the ports tested. The NodeJS VM can talk to the Couchbase VM (proven by console logs during startup). Both VMs are accessible via their Elastic IPs. For a simple NodeJS "Hello World" server on port 8000, it works fine. The main app, on port 3000, has issues.

1) The layout.jade, links to stylesheets and images log 500 errors when I call the app from outside EC2, but from another EC2 instance (the Couchbase VM) I can curl for an image and receive the file, seeming to indicate that site path settings are OK. Also, in that case, the expected 200 result code is logged by NodeJS.

2) The NodeJS logs Error: Error while establishing TCP connection. This occurs even if I am just asking for a single image file from the other EC2 VM.

Amazon support also says that the instance has logged occasional spikes to 100% CPU usage and that above approx 96% will cause the instance to lose network connectivity. However, I have been unable to cause a CPU spike by calling my app, or asking for an image file from the server, yet the TCP error is still logged.

Any suggestions of things to try will be greatly appreciated.

UPDATE: I still have the same problem, but I have eliminated my configuration of the Ubuntu 12.04 Server 64-bit AMI from the list of suspects by deploying the same app to the Bitnami 64-bit Ubuntu Node AMI (including the installation of Couchbase SDK+dependencies). The same issue crops up on the Bitnami-based instance. So, the problem apparently has to do with the app's ability to recognize its own resources.... which is still odd, because I can request those same resources (images, css files) and receive them fine, so Express is seeing them. And still I get the TCP connection error I can't explain in the log.

Here is the layout.jade that is getting all the 500s in AWS, but works fine on local Linux:

doctype html
html
  head
    meta(charset='utf-8')
    meta(name='viewport', content='width=device-width, initial-scale=1.0')
    title= title

    link(rel="stylesheet", href="/stylesheets/pure-min.css")
    link(rel="stylesheet", href="/stylesheets/grids-responsive-min.css")
    link(rel='stylesheet', href='/stylesheets/layouts/marketing.css')
    link(rel='stylesheet', href='/stylesheets/layouts/pure-skin-mmc.css')
    link(rel='stylesheet', href='/stylesheets/style.css')
    link(rel='stylesheet', href='/stylesheets/jquery.datepick.css')
    link(href='http://fonts.googleapis.com/css?family=Nunito:400,700,300', rel='stylesheet',     type='text/css')
    link(rel="icon", href="/images/m.png", type="favicon")
    script(type='text/javascript', src='/javascripts/jquery-1.10.2.min.js')
    script(type='text/javascript', src='/javascripts/jquery.validate.js')
    script(type='text/javascript', src='/javascripts/jquery.plugin.js')
    script(type='text/javascript', src='/javascripts/jquery.datepick.js')
    script(type='text/javascript', src='/javascripts/d3.min.js')
    script(type='text/javascript', src='/javascripts/mmc.js')
  body(class="yui3-skin-mmc pure-skin-mmc")
    block content

UPDATE 2: I have been able to replicate this behavior locally by pointing to the EC2 Couchbase server instance. Apparently, although connecting to Couchbase causes no error, talking to it seems to be a problem, and once it errors, the app doesn't work. It may be that this is not the fault of app components, but rather due to issues with AWS configuration.

user127
  • 111
  • 8
  • BTW, here is the console log from the NodeJS app: ubuntu@ip-172-31-13-231:~/mmc$ node ./bin/www Opening CB connection... Past connecting... index - SessionID: 991pOoY1mrzo_49cJf5hWmQrHc2xzti7 Error: Error while establishing TCP connection GET / 304 2507ms GET /stylesheets/pure-min.css 500 2532ms - 1.36kb ... the rest is omitted for space, just more 500s – user127 Aug 08 '14 at 19:43

2 Answers2

0

(I don't have enough reputation on this account to comment...)

The 500 error code means the server, in this case it sounds like your node/express app, has an error. Check the file permissions and user/group on stylesheets/pure-min.css and make sure that you can locally run

$ wget localhost/stylesheets/pure-min.css

and download pure-min.css.

It's a bit hard to diagnose with the information provided, but you can see this question about debugging HTTP 500 error codes.

You can also try wireshark to see what's happening with the requests. It looks like you're timing out at 2500 msec trying to get the file, which means whatever is serving that file is either never seeing the request, or is throwing an error.

Community
  • 1
  • 1
jimm101
  • 948
  • 1
  • 14
  • 36
0

The problem turns out to be some connectivity issue with the Couchbase server. Once the session write fails, the rest of the attempts of Express to read files also fail. Apparently, the set up of the Couchbase server AMI from AWS has some idiosyncrasies compared to the same on my local Ubuntu.

Anyway, the quick and easy solution for me was to open a free RightScale account and deploy their Couchbase Server template. Worked with no issues at all, and my NodeJS app is now as happy in the cloud as it is locally. The OCD developer in me wants to keep digging until I sort out what minor glitch was causing all this, but my deadline-meeting side says it's time to move on for now. :-)

Thanks for taking the time to try and help!

user127
  • 111
  • 8