If anyone can shed any light on this, I will be indebted to you...
I am using Net::Telnet to connect to Copper Mountain CE200's and retrieve data. Once the data has been retrieved, I update a database of port information. I have a good idea that the CE200 does not have a standard Telnet server, but can't quite account for what's happening.
If I issue a command to the CE200, then issue a second command, I sometimes get the response to the first command when I'm expecting the response from the second command. The code in my script tries to account for this and retry the whole thing, but sometimes it seems to 'stick' and I get a continual loop that ends only when I exceed the loop count I set.
I can't understand why Net::Telnet would give me the wrong response when I have no problem whatsoever with a normal Telnet client. Please understand that I am not sure that it's a problem with Net::Telnet, just that I can't understand why this is happening.
There is no doubt whatsoever that whatever the problem is, Net::Telnet is not returning the expected response, verified by printing out each line of every array returned. I've spent two weeks trying to debug. I've bumped the max-buffer-size parameter to 5 MB (well over what I expect from any response), I've thrown in code to empty the buffer almost constantly, but can't make it work. I've examined dump logs and the only real weirdness I can find is that most lines returned from the CE200 end in CR-LF-CR. The other strange thing I've observed is that most times the array of lines returned ends in what appears to be an empty element, forcing me to truncate the array.
The problem with the repeating response is very intermittent, making it difficult to pin down and reproduce so that I can take a low-level look at it. The various devices are in various remote locations under various loads, and it's never the same device twice in a row at the same point in the process. I have never observed a failure running my script against the test device in the local lab, so I believe the problem is likely affected by load or traffic. I am issuing as many as 358 requests per device/session (depending on configuration), with a new Net::Telnet object and session for each device. I empty the buffer after each $obj->cmd and after a series of $obj->waitfor, $obj->put calls to retrieve a multiscreen list. I've tried running the script from two different test servers, both with plenty of RAM, and I get the same result.
The script is 1200 lines long, so I can't post it here. I can post the "workhorse" subs if that would help (though they're a bit cluttered after all that debugging), but I have ruled out my code as the source of the problem.