4

CouchDB has an http interface that makes it accessible from the server and from the client. Does anything like this exist with a websocket interface?

Thanks in advance for any info!

fancy
  • 48,619
  • 62
  • 153
  • 231
  • 3
    I'd recommend picking your database on the merits of it doing what you need, not by the connection type it uses for clients. It's easy enough to build such an interface with Node.js or similar. I'm not sure why you would want to though. – Brad Jun 19 '12 at 20:48
  • 2
    I assure you the connection will not be the bottleneck – Mustafa Jun 19 '12 at 21:13
  • I never said I was choosing a db based on this. I asked if it existed anywhere. – fancy Jun 19 '12 at 21:44
  • mongodb has a read-only REST interface – jdi Jun 19 '12 at 21:56
  • I think that if it does exist, its going to be a 3rd party library that is specific to a driver of a specific language. The client side javascript aspect would be agnostic enough, but it would have to communicate with a server-side process that would then interact with your db – jdi Jun 19 '12 at 22:00
  • @jdi Communicating with my server and then a db is missing the point of the question. You can interface with couch over any http connection. I'm interested in seeing the same thing done with websockets. One reason is for push feeds from the db directly to the client over websocket. – fancy Jun 19 '12 at 22:06
  • I get the point of the question. I am suggesting that you are not likely to find this built directly into the db daemon process because it is too much responsibility for the role of a db. Even redis, which has pub/sub notification requires that it be part of the client library (driver). Thus, your websocket solution will end up being a layer that sits between the web client, and the db daemon – jdi Jun 19 '12 at 22:12
  • @jdi well couch does it, and has a changes feed, so check that out. I'm just talking about swapping transports to enable push notifications to the client. – fancy Jun 19 '12 at 22:23
  • Yea I see that it has an HTTP transport solution to that with long polling. So I think the answer to your question is "No, I don't believe there are any out there with websocket interfaces". Websockets have undergone a number of spec revisions so you will probably have to wait for it to become an official feature of a db, or build a proxy process yourself – jdi Jun 19 '12 at 22:28
  • Maybe this will be it.. https://issues.apache.org/jira/browse/COUCHDB-841 – fancy Jun 19 '12 at 22:30
  • Hah. And note that their comments are to close that request and start investigating a server-side events route. Its what I was telling you.. websockets haven't been a stable enough browser spec to make an official feature. But ya if you are really into CouchDB you should get involved and help with their progress. – jdi Jun 19 '12 at 22:32
  • I do not think so. Mainly because websockets are not yet supported by all major browsers. Also websockets are especially built for webbrowsers while databases are built for servers. – Alfred Jun 20 '12 at 00:16

2 Answers2

3

In general you don't want to expose your database server directly via a public interface, so there would be a server application in between providing authentication and services like websockets. Typically that would be something like node.js or Tornado .. but since you're aware of that based on your question tags, what is the actual solution you're looking for?

CouchDB currently does not directly support a websocket interface, but the next release (1.3) apparently includes support for the Server Sent Events protocol which is widely supported except for IE (see: browser compatibility).

Stennie
  • 63,885
  • 14
  • 149
  • 175
  • +1 for the server side events mention, but I disagree that a DB could not be exposed, in fact there are reasons to _only_ expose the DB, when it comes to a fully featured HTTP REST DB server such as CouchDB; consider http://stackoverflow.com/a/9507124/247623 – Erik Kaplun Mar 23 '16 at 07:24
2

It looks like CouchDB supports EventSource feed type for _changes:

https://issues.apache.org/jira/plugins/servlet/mobile#issue/COUCHDB-986

Description

I'll implement EventSource protocol feed for _changes API (feed="eventsource").

Some info about it: http://dev.w3.org/html5/eventsource/ It's more useful than websocket, beacause it's read-only.

Also: consider https://github.com/nolanlawson/socket-pouch:

SocketPouch a custom PouchDB adapter that proxies all PouchDB API calls to another PouchDB running on the server in Node.js. The communication mechanism is Engine.io, the famous core of Socket.io.

This means that instead of syncing over HTTP, SocketPouch syncs over WebSockets. Thanks to Engine.io, it falls back to XHR polling in browsers that don't support WebSockets.

PouchDB is a port of CouchDB in JavaScript, meant to run inside the browser (for running a CouchDB database in the browser) or/and Node.js (as a lightweight substitute or complement for CouchDB)

Erik Kaplun
  • 37,128
  • 15
  • 99
  • 111