How to let server send the message first in GRPC using python - python

Hi i am new to GRPC and i want to send one message from server to client first. I understood how to implement client sending a message and getting response from server. But i wanna try how server could initiate a message to connected clients. How could i do that?

Short answer: you can't
gRPC is a request-response framework based on HTTP2. Just as you cannot make a website that initiates a connection to a browser, you cannot make a gRPC service initiating a connection to the client. How would the service even know who to talk to?
A solution could be to open a gRPC server on the client. This way both the client and the server can accept connections from one another.

Related

Best practice to handle passwords/keys in python

I am developing a client and a server in python. The client connects to the server and send requests for the server to perform specific tasks. In one of the tasks the server needs to connect to a ssh server using a private key. Is there any good way to store this private key? Should it be stored in the client or in the server? If stored in the client, what would be the safe way to send it to the server when needed? I don't really want to have the need to type a password in the client everytime.
Thanks.

Communicate with a specific client [JS/PY]

I use angular client side (TS) and Django server side (PY).
Unfortunately despite what I find on the internet, I can't send a message to a SPECIFIC client from the server. Socket.io doesn't exist in PY, I've seen the websockets but that only talks about sending a message to ALL clients in a group. But if I want to send a message only to a client B I don't see how to do it.
Please help me, and guide me on the solution to use
PS: I'm starting with the PY backend, be indulgent.
Thank you.

django save websocket to redis without closing it

Is there a way to keep websocket open using redis for future use ?
I need my django server to communicate with a websocket backend service on behalf of the client.
It means that I need to save the websocket open between multiple http requests of the client.
can I use redis for this purpose or is there any other way to do so ?
Thanks.

Push notifications from web server to desktop app in python

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.

How to maintain server-initiated FTP connection between client requests in Python/Django?

I'm going to use ftplib to open up an FTP connection to an FTP server provided by the user. The client will be sending FTP commands to my django server via Ajax, which will then be forwarded to the FTP server the user provided. However, I'd like to not have to create a new FTP server connection every time the client sends an FTP command. In other words, I want to keep the FTP connection alive between requests by the client.
How would I do this? Would some sort of comet implementation be best? I was initially planning to use WebSockets until I discovered my host won't allow it. =\
You'll need to use a persistent connection framework as what you're trying to achieve really isn't what HTTP was meant for (in the sense that HTTP commands are stateless and independent), and thus not what Django is built for. There are a number of options, but since it seems you are in a restricted environment you'll need to do some research to determine what's best.
Switch hosts. Webfaction allows websockets with dedicated IP at around $20 per month.

Categories

Resources