WebSocket with free RDMBS (PostgreSQL, SQLite, etc) and without JavaScript ecosystem - postgresql

I'm searching a simple implementation to push changes from a free relational database (PostgreSQL, MySQL, SQLite, etc.) to clients' browsers via WebSocket or WebPush.
I want to avoid all the server-side JavaScript ecosystem (Node.js, npm & cie) and the NoSQL databases.
All must be hosted in the servers of my company, I can't use third-party services.
I found these interesting solutions :
http://initd.org/psycopg/articles/2010/12/01/postgresql-notifications-psycopg2-eventlet/ [with Python]
https://gist.github.com/drocco007/6e44ac1a581546c16e67 [the same one slightly improved]
https://coussej.github.io/2015/09/15/Listening-to-generic-JSON-notifications-from-PostgreSQL-in-Go/ [with Go]
Do you know other ways to get this done?
Is PostgreSQL the more suitable free RDBMS to do this?
Can it be accomplished with a SQLite database?
Can Apache or NGinx abilities be used to achieve this?

Update 01/23/17: I wrote an application called postgresql2websocket in order to send PostgreSQL notifications over websockets using Python 3 with asyncio + aiohttp + asyncpg https://github.com/frafra/postgresql2websocket; you could combine it with PostgREST in order to have both standard REST APIs and realtime updates using WebSockets.
As far I know, there is no HTTP server extension for using SQL databases with Websockets without anything in the middle.
You can use Python on the server side, like this: Real Time Web Apps with (just) Python and Postgres. I think it could be improved thanks to aiopg. If you don't need Websockets, you can just use ngx_postgres.
If you like Django, Django Channels will be probably included in Django 1.10 (Redis/in-memory/... layer for channels and SQL backend).
You could use SQLite, but bear in mind that you have to implement a separate server side publish/subscribe mechanism (like Django channel does), because SQLite doesn't have one.
If you're just interested in pub/sub over Websockets, you could use Webdis (Redis-based solution): it would be probably lighter than a full SQL database.

Related

Availability of WebSocket servers (specifically on AWS RDS)

So, I've created a MySQL database on AWS RDS, and written a client desktop application in a .NET application that uses Sockets to authenticate with, connect to, and manipulate the database, using the endpoint ("xxxxxx.rds.amazon.com") and username/password. This works great.
I was trying to see if I could accomplish something similar in client javascript. It seems like the analogous API it offers is WebSockets, which I am familiarizing myself with. However, it seems to me (mostly from the absence of how-to's on the web) that that endpoint ("xxxxxx.rds.amazon.com") is accessible via Sockets, but not via WebSockets -- and that there is not an alternate route to my MySQL database for WebSockets. Is this correct?
It makes sense that these are two different types of servers, but generally speaking internet resources are served out to Sockets, but not WebSockets? If that is true, they are not as analogous as I originally thought; is WebSockets mostly good for communicating between WebSockets clients and servers that I create? Or can it be used to access good stuff already existing on the internet, as Sockets can be?
(Note: this isn't asking for opinions on the best way to do this, I'm just confirming my impression of the specific way these technologies are used.)
Thank you.

To run a GraphQL server in Python that allows queries and subscriptions, do I have to combine it with a web framework service?

Excuse my ignorance in this area: most of my programming has been in optimization and research. I am very new to GraphQL and client-server programming.
My organization is working on an automated scheduler in Python 3.9 for scheduling observations for a large-scale telescope.
We are relying on many different services to all communicate via GraphQL. At the moment, I am trying to implement a GraphQL server that can be queried or accept subscriptions to disseminate when a new schedule for the night is created (for any number of reasons such as changing weather conditions, instrument faults, modifications to observations). Eventually, we will need to allow mutations (e.g. to the priority of observations, or to fix an observation at a given time).
I am looking at both Strawberry and Graphene as my possible options, but what is unclear to me is if I require them to be combined with a web framework service like Django or Flask to achieve the functionality that I need.
I see that Strawberry has a built-in (possibly only debug) server, but it also discusses integration with Django, Flask, and others, and I am not certain if I need to go to that level. I have been working through examples and completed a JavaScript course using Apollo Server / Client, but I'm not sure how these compare to Python GraphQL server implementations.
I apologize for my lack of knowledge: I am trying to keep the project as simple as possible for now, and having played around with Graphene and Django, I'm not sure if I'm overcomplicating things of if this approach is necessary.
Statements like "Graphene is fully featured with integrations for the most popular web frameworks and ORMs" lead me to believe a web framework is required, but again, I am not sure and feel very out of my depth since in this area is virtually nonexistent.
I'm the maintainer of Strawberry GraphQL 😊
For both Strawberry and Graphene you'd need framework like Django or Flask.
Strawberry has support for Subscriptions when using an ASGI framework like Starlette or FastAPI, there's some example here: https://strawberry.rocks/docs/general/subscriptions#subscriptions
We also have an almost-done PR that adds support for subscriptions using django: https://github.com/strawberry-graphql/strawberry/pull/1407

How can i implements an online chat?

Ok, let's say that there's a company (let's say e-commerce) that has to implement a support chat on its website. Do you know what are protocols/infrastructures needed?
I've seen XMPP but I don't know if it's really useful in my case...
Ty a lot!
If you need to implement all things yourself, and don't want to use XMPP server, you can create your own chat protocol.
Such a protocol can be based on JSON-RPC.
Also, you can make a simple protocol using only features from Socket.IO.
You can use Socket.IO both on the server and client-side.
You will also need a database for storing chats and messages.
If you anticipate very heavy traffic, you can use e.g Apache CASSANDRA, but a plain SQL (or noSQL) database will be sufficient for most implementations.
It is better to use a database you are familiar with. The PostgreSQL can be a good choice because it has nice JSON support.
If you prefer a noSQL database, MongoDB will be OK.
If you use React, for the frontend I recommend you to use a #chatscope/chat-ui-kit-react components together with the #chatscope/use-chat library (I'm the author of both of them).

Does Meteor.js work with ArangoDB?

The answers to Does Sails.js or Meteor.js work with ArangoDB or OrientDB? do not contain info specifically about Meteor/Arangodb combination.
This is what I need to know: how close is ArangoDB to state of being a drop-in replacement for Mongo in Meteor?
The reasons I would prefer to use Arango:
friendlier license (Apache vs Mongo's AGPL)
graph db features built-in (I'm going to need that)
ACID transactions
Out of the box, Meteor only supports MongoDB directly, so there is no real "drop-in" alternative to MongoDB if you are a bleeding heart Meteor developer.
Because the Meteor server is built on top of Node.js you can simply use the JavaScript driver for ArangoDB to talk to ArangoDB from your server-side Meteor code. Alternatively you can simply use the ArangoDB HTTP API directly.
For a less database-specific solution you can look into Apollo as BennyB pointed out, but keep in mind that Apollo communicates using GraphQL, which while offering a lot of flexibility to frontend development also creates certain limitations for backend development, especially when it comes to optimizing queries for performance. A naive implementation of a GraphQL schema treats the database purely as a key-value storage, which will not play into the strengths you're interested in (specifically transactions won't be available this way).

Open Source Secure Sockets Framework

I am looking for an open source framework to build a proprietary protocol onto (Agent/Client talks to a Receiver/Server that stuffs things into a SQL database).
I need session handling (ie login/logout) and some kind of encryption.
I found the Spread Framework which looks great, but does not appear to support authentication or encryption of any kind out of the box.
My preferred language is C, C++, Python, or Perl.
Anyone know of anything off hand? Hoping for something to be out there to save me time rather than doing it the hard way all in *nix sockets ;)
Thanks in advance!
Why not use libcurl, as it can do SSL.
http://curl.haxx.se/libcurl/c/example.html
DJango and DJango ORM, or SQLAlchemy combinations can be a good start. A python base framework and ORM.
Since you are working at the socket level, I assume that you are trying to write an application from the ground up. Or are you trying to run within an existing web server?
Could you use lighttpd with HTTPS & mod_cgi? This isn't really a framework, per se, but it would keep your application portable to other infrastructures.
On the server side, CGI::Session could take care of the session management. Authentication could be done using mod_auth.
Why not use SSL/TLS? On the client you can use libcurl, which works with C, C++, Python, and Perl. On the server, use Apache, lightttp etc, with cgi or your favorite language. You can use mutual authentication to ensure verify the identify of both the client and server, as well as provided an encrypted channel.