python-socketio websocket emit to particular client in Socket.IO an ionic application - django

In my project I am using a Django application that acts as a SocketIO server to the Ionic mobile application which uses Socket.io to connect to the server as a client. My django application has another socket connection and it acts as a client to another micro service in python which uses python-socketio to create a websocket server. When I send a request from the Ionic application, it reaches the Django server which sends the request to the client via Django signals and then the request is sent to the micro services and the response from them are to be sent to the same Ionic application via Django. I was able to do it successfully when the Ionic application is only one. When there are multiple Ionic clients and when the data is different for them both, this does not make an effect. Both the clients receive the same data. My requirement forces me to have the communication through the Django server. Can anyone help me with this?
Microservice (python-socketio) <--> Django (python-socketio) <--> Ionic application (socket.io)
The communication is by websockets by eventlet.

Related

Send missed notifications to a client when webscoket connection is made

I am developing a chat application with django channels. But I have a problem. How can I make client application sync with the server. If the client application disconnect and reconnect it will lose the changes. How can I make the client application synced with the server. Sorry for bad english.

Daphne server unable to handle http requests

I have a django application that I want to deploy using daphne.
Django application supports both websockets and http requests. I've converted the django to support ASGI.
I'm starting the server using :
daphne <project_name>.asgi:application
The server is able to accept websocket connections but unable to handle the incoming HTTP requests (throws 404).
Where am I going wrong over here?
P.S.: I'm not using django channels.
I had forgotten to instantiate 'get_asgi_application' while creating the django application. Hence, it wasn't able to accept HTTP requests.

How to use React Native's WebSocket with cookies

I have a real-time server with WebSocket and cookies. to authentication i should send two cookies to server with Websocket.
how can i use React Native's Websocket with cookies
according to this link "As of React Native 0.38, this should happen automatically on Android" but HOW??
this is undocumented feature:
React-Native's websocket structure is below:
ws = new WebSocket(url, protocole, extraHeader);
your send extraHeader as object (such as Cookie, authentication-key and etc) to websocket server.
it's tested in android and working fine. and according to this answer it's working in iOS as well as Android

Is it possible to use django as a proxy for websoxket

I have a service (written in erlang) that accepts websocket connection from my django application. Django serves the page and the js script that makes the calls to the erlang service.
Now I want to go through the django server also for websocket connection and messaging. That is to use django as a proxy that forwards websocket connection and messages from the client to the Erlang service and sends back responses from the erlang service to the client. Optionally django should also check request authorization before forwarding them.
Is that possible?

Keeping connection open in Django without websockets

I have a mini computer that does not support websockets that I would like to receive push notifications from a server.
The issue is that after the client connects to the server, the server responds and then closes the connection. This makes it so the client has to continually reconnect to the server to get new information.
Is there a way using Django to allow the connection to be left open and then have the server publish data to the client?
Django is primarily a request/response framework and as such does not have support for real duplex communication.
Socket.IO is the de facto library that makes websocket-like functionality cross-browser (IE5.5+), using real websockets as a transport if the browser allows it, falling back to HTTP long-polling or whatever else if it doesn't. For various options on integrating Socket.IO with Django, read this.