couch-client
couch-client copied to clipboard
Works on localhost, crashes using Cloudant
Using the same database works find on local, but when replicated to Cloudant the connection crashes Node.js with an exception:
undefined:1
SyntaxError: Unexpected token ILLEGAL
at Object.parse (native)
at IncomingMessage.
I can connect to the db using curl and retrieve data, and Node's JSON module can parse the data retrieved by curl just fine, so I'm not sure what's going on.
Interesting. Any idea if the bug is in my code, node itself, or something cloudent it doing wrong?
Can you trace the data going back and forth using pcap or something?
I've dug into it further. There are several things going on. The unexpected token is because the server is returning
<html><body><h1>503 Service Unavailable</h1> No server is available to handle this request. </body></html>
when called by CouchClient.
CouchClient also assumes port 5984, and Cloudant is running on port 80, so I need to specify port 80 in my connection url, where curl assumes port 80.
Finally, CouchClient seems to throw away information about secure sockets, so it is not connecting over https.
I've gotten far enough to bring Node and CouchClient up, but it appears to be unresponsive now, will give you some more info when I get it.
I think I am having a similar issue. I can connect to a CouchDB instance locally, but using Cloudant via heroku over https fails. If I curl my couchdb running on cloudant, I can connect to the database. However, attempting to do the same with CouchClient gives me this:
2011-06-07T14:45:12+00:00 app[web.1]: node.js:134
2011-06-07T14:45:12+00:00 app[web.1]: throw e; // process.nextTick error, or 'error' event on first tick
2011-06-07T14:45:12+00:00 app[web.1]: ^
2011-06-07T14:45:12+00:00 app[web.1]: TypeError: Cannot read property 'rows' of undefined
2011-06-07T14:45:12+00:00 app[web.1]: at /app/node_modules/couch-client/lib/couch-client.js:170:21
2011-06-07T14:45:12+00:00 app[web.1]: at ClientRequest.errorHandler (/app/node_modules/couch-client/lib/couch-client.js:47:23)
2011-06-07T14:45:12+00:00 app[web.1]: at ClientRequest.emit (events.js:64:17)
2011-06-07T14:45:12+00:00 app[web.1]: at CleartextStream.
I'm seeing the same issue as @mhemesath
I got around it by doing this:
new CouchClient(process.env.CLOUDANT_URL + ":443/myDocument")
awesome, that worked :) thanks!
I logged an issue specific to this problem here: https://github.com/creationix/couch-client/issues/29