========================================================
from twisted.internet import protocol, reactor, defer, interfaces

class MyProtocol(protocol.Protocol):      
    is_big_data = False
    big_data = ''
    big_data_size = 0
       
    def connectionMade(self):
        self.big_data = ''
        self.big_data_size = 0
        self.is_big_data = False
        pass

    def dataReceived(self, data):  
        if check_head_ok(data):
            # To receive the big size data
            if self.is_big_data:                
                return

        # The big data will overflow the Twisted receive buffer size, so loop to receive data
        if self.is_big_size_data:
            self.big_data += data

        if self.big_data_size == len(big_data):
            # To save data to database
            pass
                         
    def connectionLost(self, reason):
        self.big_data = ''
        self.big_data_size = 0
        self.is_big_data = False
        pass
       
    def check_head_ok(self, data):        
        if data.startswith('ABC'):
            values = data.split(',')
            self.big_data_size = int(values[1])
            self.is_big_data = self.big_data_size > 0
            return True
        else:
            return False 
================================================================

I rewrite my source about MyProtocol. But I can not receive complete data, only a part of data. :( Could you help me?