clojure-clutch / clutch

A Clojure library for Apache CouchDB.
Other
225 stars 37 forks source link

watch-changes is faulty #36

Open kzar opened 12 years ago

kzar commented 12 years ago

I've noticed that the watch-changes feature doesn't always work.

With 0.2.5 I used it successfully on my development database running on the same machine but I was unable to use it in production with the database running on a separate machine.

With 0.3.0-SNAPSHOT I wasn't able to get it working on either a local development database or a remote production one.

In both cases the watch-changes function ran successfully and changes-error came back empty.

Here's a snippet showing what I did:

  (ns scratch.core
    (require [com.ashafa.clutch :as clutch]))

  (def prod-db "http://user:pass@remote-host/dbname")
  (def dev-db "http://localhost:5984/dbname")

  (clutch/watch-changes prod-db
                        :prod-print println
                        :include_docs true)

  (clutch/watch-changes dev-db
                        :dev-print println
                        :include_docs true)

  (clutch/changes-error prod-db :prod-print)

  (clutch/changes-error dev-db :dev-print)

Cheers, Dave.

cemerick commented 12 years ago

Just to clarify, you say that watch-changes ran successfully — do you mean that that particular call succeeded, but your callback function (println in your examples) was never called?

Were there any stack traces, either on the Clojure or couchdb side?

kzar commented 12 years ago

Exactly, the watch-changes function returned successfully but println was not then called.

There where no stack trace or errors shown with changes-error and I can't see anything in couch.log.

kzar commented 12 years ago

I've just tested out the new version of clutch, watch-changes works again with a local database but I still can't get it working with a remote one. I guess there's a second bug somewhere :(

cemerick commented 12 years ago

Damn, you're right. Confirmed with Cloudant. The HTTP agent that sits on the _changes feed is disconnecting for some bizarre reason, but not when connected to localhost. :-/