MY AMI is not working

i am using asterisk 1.4.28, i am trying to read the queue status as well as agent status for realtime monitoring of a call center… My page will actually update after every 5 second to show the realtime status of a call center agents. i am trying to use below AMI code but my output does not end, i am not getting END LINE… is any one here help me out?

    $oSocket = fsockopen("127.0.01", 5038, $errnum, $errdesc,20) or die("Connection to host failed");
    fputs($oSocket, "Action: login\r\n");
    fputs($oSocket, "Events: on\r\n");
    fputs($oSocket, "Username: test\r\n");
    fputs($oSocket, "Secret: test\r\n\r\n");
	fputs($oSocket, "Action: QueueStatus\r\n");
	fputs($oSocket, "ActionID: 234\r\n");
	fputs($oSocket, "Interface: Agent/1000\r\n");
	fputs($oSocket, "Queue: test\r\n");
	fputs($oSocket, "Action: Logoff\r\n\r\n");
			$wrets .= fread($oSocket, 8192);

I believe your missing a \r\n on the queue line.

since that is the end of the QueueStatus action, you need to send a blank line to indicate the end of the send.