I am trying to work out how I can get Django Server B(IOT device) to subscribe to Django Server A (cloud) using Channels WebSockets.
This is so that I can pass data async between them. Server B will be on an IOT device and Server A will be cloud-based. I've been looking everywhere, but most of the online tutorials and documentation seems to be based on subscribing(client-side) with Javascript. Surely there must be a way to subscribe with Python! Most of the online tutorials seem to be for chat apps too. It would be great if someone could help please. I'm sure there are other people looking for this same answer too. Thank you :)
Related
So I have a basic question about WebRTC with Python Django.
Maybe I start at the beginning:
So is it possible that Python Django can serve as a Server for WebRTC? I think in generell it shouldn't be that hard, because how I saw the WebRTC client only needs a Websocket connection. I hope anybody can help me with that. Btw. I use Django Channels, so I think it is possible to build this connection, but how? :)
I would guess they're not recommending it above because it gets complicated very quickly implementing WebRTC video calls on your own with cross-browser support (Safari, especially). Using existing video APIs that have done that work for you can be a great option for a lot of companies to avoid all the edge cases that affect video quality. Daily, Agora, Twilio are all video API options that can handle this work for you.
It's not impossible but I do not recommend!
Instead, there are some WebRTC media servers like Jitsi, AntMedia and Janus. I used the last one on one of our project with Django.
Checkout microservices achitecture and find a way to combine your project with Django (for Authentication, Authorization and other processes) + WebRTC Media Server + Frontend and/or Mobile App. May Frontend could be in same code base with Django, up to you.
I have followed a couple of tutorials about interactive/real-time applications using STOMP over WebSockets with the Spring framework using the messaging layer.
Example in Spring
I would like to implement the same functionality in clojure. Has anybody experience in implementing a similar application? I have been looking for documentation/examples about using these technologies, but there is nothing like the examples in clojure.
That it makes sense? Is it necessary to have an external message broker to connect the backend app and the browser clients?
I have some experience using a broker to pass messages along. However, I think it's still best to write your own http frontend for the browser to talk to. That frontend in turn can post messages to a broker (using Stomp or any other protocol). That way, you have more control and you're not tied to a message broker. For instance you can have the frontend do more than just websockets, like serve static files, or a regular HTTP interface.
But that's up to you, if the broker supports websockets, you can use that too (see for instance ActiveMQ). My advice is: try the simplest possible way first :-).
Take a look at Http-kit for a good Clojure webserver. It also has good websocket support.
I am currently developing an instant messaging feature for my apps (ideally cross platform mobile app/web app), and I am out of ideas to fix my issue.
So far, I have been able to make everything work locally, using a Node.js server with socket.io, django, and redis, following what most tutorials online suggest.
The step I am now at consists in putting all that in the cloud using amazon AWS. My Django server is up and running, I created a new separate Node.js server, and I am using Elasticache to handle the Redis part. I launch the different parts, and no error shows up.
However, whenever I try using my messaging feature on the web, I keep getting an error 500:
handshake error
I then used the console to check the request header, and I observed that the cookies are not in there, contrary to when I am on localhost. I know it is necessary to authorize the handshake, so I guess that's where my error is coming from..
Furthermore, I have also checked that the cookies do exist, they are just not set in the request header.
My question is then: How can I make sure Django or socket client (not sure who's responsible here..) puts the cookies in the header??
One of my ideas was that maybe I am supposed to put everything on the same server, with different ports, instead of 2 separate servers? Documentation on that specific architecture problem is surprisingly scarce, compared to the number of tutorials describing how to make it work on local.
I hope I described the problem accurately enough! :)
Important note: I am using socket.io v0.9.1-1, only one compatible with a titanium mobile app.
Thank you for any help!
All right, so I've made some progress.
The cookie problem came from the fact I was making cross-domain request, adding a few lines enabled CORS, which didn't solve the cookie issue, but allowed me to communicate between servers (basically I set the headers of the response using express. I then passed necessary data in the query, even if not the most secure way to do it, I'm just building an MVP, and it's enough for now.
I haven't been able to make the chat work from my Titanium mobile app, but since I can use a webview to handle it, I will be fine.
Hopefully that will help someone.. If anyone needs me to post some code snippets I will gladly do so upon request!
Cheers
I am looking for a chat solution that I can integrate into my mobile app. So far, I have been looking into python solutions and have come across the "chat demo in tornado" library. Are there any more advanced solutions that I can look into ?
CHat demo link : https://github.com/facebook/tornado/tree/master/demos/chat
There is this play2 (java) app that has been developed as an example by Heroku that makes use of Redis and WebSockets: https://github.com/heroku-examples/play-websockets-chat-sample
It could be helpful.
There are lots.
Some django based are:
Using the excelent pusher.com service: https://github.com/andres-torres-marroquin/django-pusher-chat
https://github.com/qubird/django-chatrooms
uing comet: https://bitbucket.org/nicoechaniz/django-live/src
with tornado and websockets: https://github.com/aruseni/chat
https://github.com/sveetch/djangotribune
http://code.google.com/p/django-chat/
http://code.google.com/p/django-jqchat/
Some Flask based:
using gevent and websockets: https://github.com/kcarnold/flask-gevent-socketio-chat
using gevent and websockets running on heroku: http://callmephilip.github.io/chatzilla/
using websockets on heroku: https://github.com/heroku-examples/python-websockets-chat
I'm pretty sure that there are chat apps for most of the python web frameworks we know. I've listed only those for django and flask because they are my favourite web frameworks.
I know a chat software named 123 Flash Chat. I guess it will totally satisfied with your request. They provide mobile chat app integration for ios and andriod. You can have a try, hope it will help you. :)
http://www.123flashchat.com/mobile-chat-promo.html
http://www.123flashchat.com/build-mobile-chat-app
If you are looking for an android (JAVA) chat library I recommend MQTT chat. It is more than a library, a complete messenger with extremely fast messages dending using the MQTT protocol and also it provides audio and video calls with webrtc. integration is also very easy. Even a beginner in Android can integrate it
As mentioned here
https://github.com/blog/1174-auto-updating-comments
What is the technology behind this? If I've to add this feature in a Django powered web app, what should I use and study?
Looking at network tab it looks like they (at least with chrome) are using HTML5 Server Sent Events.
So practically the browser subscribes to a event stream and the web server just sends messages back.
I am not an expert but I guess on the server side you need to be able to keep an open connection that streams the events to the client.
I found an implementation of SSE for python here: https://github.com/niwibe/sse and a django implementation on top of that: https://github.com/niwibe/django-sse
I did not use them (yet) on any production so I suggest them only as study / poc material :)