当新数据收到套接字时,Windows会断开连接

时间:2013-05-30 08:01:20

标签: python sockets python-2.7 windows-server-2008 twisted

我做了扭曲的服务。在我搬到新服务器之前,一切正常。现在,我的服务在收到新数据时会丢弃大多数连接。 旧服务器安装了32位Windows XP,新服务器是英特尔服务器上的VMWare VM,带有Windows Server 2008 64位。两个服务器上的Python和扭曲版本都是相同的。

在这里您可以看到问题的片段:

ConnectionLost reason is: Connection to the other side was lost in a non-clean fashion.

Python版本是2.7.5,Twisted 12.3

这是示例代码:

# -*- coding: utf-8 -*-
from twisted.internet import protocol, reactor
from twisted.python import log

class GreenProtocol(protocol.Protocol):

def __init__(self):
    self.ip = ''
    self.port = 0

def connectionMade(self):
    self.ip = self.transport.getPeer().host
    self.port = self.transport.getPeer().port
    log.msg("[{0}:{1}] NEW CONNECTION".format(self.ip, self.port))  

def dataReceived(self, data):
    log.msg("[{0}:{1}] DATA".format(self.ip,         self.port))                                    

def connectionLost(self, reason):
    log.msg("[{0}:{1}] CONNECTION LOST".format(self.ip, self.port)) 

class GreenFactory(protocol.ServerFactory):
    protocol = GreenProtocol

if __name__ == '__main__':
    factory = GreenFactory()
    reactor.listenTCP(5678, factory)
    log.startLogging(DailyLogFile('log.txt', 'logs'), setStdout=False)
    reactor.run()

建立连接后,每个客户端都会发送一条消息。但是只记录了5-10条消息中的1条。大多数客户端在发送消息后丢失连接,并且服务器未收到消息。

显然,原因是:

Connection to the other side was lost in a non-clean fashion: read error -- unknown (64)
P.S:我认为这不是扭曲的错误,因为当我用嗅探器听时,我会得到相同的结果。

P.P.S:大约有700个客户端,其中只有70-100个可以发送数据,所有其他连接都被丢弃。

1 个答案:

答案 0 :(得分:1)

我找到了解决方案。问题是,供应商在没有任何通知的情况下改变了关税计划。新的资费计划限制了最大连接数。