In the dataReceived method, you return the data as a string of indefinite length, which means that it can be a complete message in your protocol or it can only be part of the message that some "client" sent to you. You will need to check the data to see if it contains the whole message in your protocol.
I am currently using Twisted in one of my projects to implement the protocol and decided to use a structural module to pack / unpack my data. The protocol that I implement has a fixed header size, so I do not create any messages until I read at least HEADER_SIZE the number of bytes. The total message size is declared in this part of the header data.
, , . , , , /. FIX SOH . , , ( ).