I am building a chat application that consists of a Django web backend with a Node.js/socket.io powered chat server. There will be instances when changes made via the web interface (e.g. banning a user) need to be pushed immediately to the chat server. I can think of the following options:
Use a Python-based socket.io client to interface directly with the server (what are some good Python clients?)
Use redis or a message queue to do pub/sub of events (seems like overkill)
implement a simple TCP wire protocol on a secondary localhost-only port (this could be done using the built-in Node and Python TCP libraries)
What would be the best option?
Expose a Restful API on the chat server. Then your Django web application can easily make API calls to modify state in the chat server.
Doing anything else is more complicated and most likely unnecessary.
Related
I'm trying to build a notification system that would be triggered initially from an api call made on the cloud, and should trigger a notification on one of my agents' pc (assuming running windows 10)
I'd like to do that in python as this is my knowledge
How should I structure this ?
The hardest part I can't figure out and couldn't find anything online is how to link the "local" pc to the "server"/cloud system (i'm using aws if that is useful) which would store the notification and dispatch them for each one of my agent.
My ultimate goal is to use a phone solution like aircall and to show the contact name of the caller through a notification popup in windows (aircall does offer that natively but can't access my contact datrabase so i'm trying to override the same function of displaying the caller name)
any help or suggesiton appreciated
One solution could be to build a simple ElectronJS frontend app that runs on your agents' computer AND a Python web server that listens to Aircall's Webhook events.
The web server would listen to call.ringing_on_agent Webhook events sent from Aircall and send a WebSocket push event (using Pusher for example) to your ElectronJS app.
The ElectronJS app installed by your agents would listen to WebSockets from your Python web server and would trigger a native Windows notification with the information you want (check the doc here).
I had implemented a real-time chat application web service which gives services to the web and mobile client. I found that channel makes separate sockets for every user and bind them in groups and rooms in Redis handling where a specific socket message should be sent.
So in this case, for example, the mobile platform has to save which sockets belong to which rooms and groups and in every message sending from the server, the mobile platform has to check what room this message belongs and send it on. think big like telegram and WhatsApp. it seems to me that it's not appropriate client saves multiple sockets for every user communicating with one server. Am i right??
Also in cases like WhatsApp(large scale applications) servers have sockets for every user in every room if they choose the Django channel. it makes a lot and lots of ports busy on the server.
I have experience implementing socket implementation using Redis, SocketIo, Laravel to. using these tools, I was free to use few sockets for sending all kinds of notifications to users using few socket ports. it was seemed lighter than Django channel.
With these kinds of thinkings, I have doubt to continue using Django channel in my project, and I am a little worried about when it deploys in large scales.
Should I be worried??
I knew that client polling is bad and not recommended for enterprise level applications.
Do we have any 3rd party which notifies client whenever there is a change in data?
Assuming that your backend is a Scala based Web application, you could then expose a Websocket endpoint to which your client subscribes. You then could push data as soon as there is some change in the backend. Whoever is subscribed to this Websocket channel, will get this update.
I have an existing chat socket server built on top of twisted's NetstringReceiver class. There exist Android/iOS clients that work with it fine. Apparently web sockets use a different protocol and so it is unable to connect to my server.
Does a different chat server need to be written to support web sockets?
“Yes.”
If you'd like a more thorough answer, you'll have to include more information in your question.
I have a service with users (in django) and desktop client for this srevice (on wxpython). I need to send notifications from server to desktop app for specific user.
What I can use for it?
Thank you!
I don't know wxPython, but if you want to use long-polling, comet or another technique based on HTTP protocol, then you need to write HTTP client or use any network framework.
For example Twisted.
Make connection to your django server and send data through TCP transport using HTTP protocol.