【发布时间】:2025-12-19 00:55:01
【问题描述】:
我已经在 azure 上上传了我的 python 套接字(云服务项目),并且当我连接到 Hercules 客户端套接字时......在一两条消息之后,远程主机关闭了连接......强行...... .?
服务器代码
from twisted.internet.protocol import Factory, Protocol
from twisted.internet import reactor
import SocketServer
class IphoneChat(Protocol):
def connectionMade(self):
self.factory.clients.append(self)
print('clients are'), self.factory.clients
def connectionLost(self, reason):
self.factory.clients.remove(self)
def dataReceived(self, data):
msg = ""
msg = data.strip()
for c in self.factory.clients:
c.message(msg)
def message(self, message):
self.transport.write(message + '\n')
print ('Iphone Chat server startedd')
factory = Factory()
factory.protocol = IphoneChat
factory.clients = []
reactor.listenTCP(9073, factory)
reactor.run()
【问题讨论】:
-
项目是作为辅助角色运行还是仅在 Azure VM 实例上运行?
-
是的,作为工人角色....?
-
在我的解决方案中,我有两个项目,一个是工作角色,第二个是 python 云服务,工作角色在发布到 azure 之前作为 statup 项目......
-
这个项目是什么?