Variable AMI message length

Hi all,

I’m having a little problem with my AMI parser.

First of all, I’m using Asterisk 1.8.12.1 and I’ve created an AMI parser which will make it possible to control asterisk with another tool. However, I’m getting some trouble with the message length used by asterisk. In my code, I start a thread which will be listening on a telnet tcp socket and every time I get a message containing the string “Event: hangup” I do some actions. The problem is that when the message I get contains more than one “Event:hangup” the information about the channel being hangup is lost, so I’d like to know: Is there any way to set a maximum length for the AMI messages sent by Asterisk?

Any help will be appreciated,

Ben.

It is the OS TCP layer that is consolidating the messages. Google “Nagle algorithm” for details.

The correct way to handle this is accumulate everything between paired newlines, even if it is split across two frames.

hey David55 thank you!

When you say Paired newlines you mean “\n\n” or “\r\n” ?

Sorry but it has been an issue since I started with all this stuff…

Thanks in advance!

Ben.

Ok, you meant “\r\n\r\n” actually…

Thanks david!