简体   繁体   English

如何在Python / Django中的客户端请求之间维护服务器启动的FTP连接?

[英]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.

相关问题 如何在Python Sockets程序中维护多个客户端和服务器之间的连接 - how to maintain connection between several clients and server in a Python Sockets program 如何将远程 Python FTP 服务器连接到本地 Python FTP 客户端 - How to connect remote Python FTP server to local Python FTP client 如何在Python客户端服务器套接字编程之间实现SSL连接 - How to implement SSL connection between Python client server socket programming 我们如何通过套接字编程(Python)与不同网络上的服务器和客户端建立服务器和客户端之间的连接? - How could we establish connection between server and client through socket programming(Python) with server and client on different networks? 服务器/客户端连接(Python) - Server/Client Connection (Python) socket.io客户端和龙卷风python服务器之间的Websocket连接 - Websocket connection between socket.io client and tornado python server python - 服务器如何启动与客户端的连接 - python - how can server initiate a connection to client 使用Python在FTP服务器上的不同文件夹之间导航 - Navigating between different folders on FTP server with Python 在同一端口上使用Python Port / Socket进行多个连接,如何为每个客户端(预期有100万个客户端)保持稳定的连接 - Python Port/Socket multiple connection on same port, How to maintain stable connectivity for each client (expected 1 million clients ) 如何在 Python 的请求中使用 FTP - How to use FTP with Python's requests
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM