[英]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. 我将使用ftplib打开与用户提供的FTP服务器的FTP连接。 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.
客户端将通过Ajax向我的django服务器发送FTP命令,然后将其转发到用户提供的FTP服务器。 However, I'd like to not have to create a new FTP server connection every time the client sends an FTP command.
但是,我不需要每次客户端发送FTP命令时都创建新的FTP服务器连接。 In other words, I want to keep the FTP connection alive between requests by the client.
换句话说,我希望客户端之间的FTP连接保持活动状态。
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.
最初,我计划使用WebSocket,直到发现主机不允许使用。 =\\
= \\
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. 您将需要使用一个持久连接框架,因为您要实现的实际上不是HTTP的目的(在某种意义上,HTTP命令是无状态且独立的),因此不是Django的目的。 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.
Webfaction允许具有专用IP的websocket每月约20美元。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.