Results 1 to 5 of 5
- 08-02-2011, 07:08 PM #1Member
- Join Date
- May 2010
- Rep Power
Problem with apache.commons.telnet library
I am using the apache.commons.net.telnet library (Example of use of Telnet Client : Telnet*«*Network Protocol*«*Java)
I used the example provided in the link above to connect to a Mikrotik router board but I got the following issues:
1- When I use the telnet client in windows to communicate with the Mikrotik everything works just fine and there is no delay, but when I use the library mentioned above it takes about 4 to 5 seconds to get a response from the device for every command.
2- I am encountering what seems to be encoding problems: for example when I type the username and password I get [m36 [m36 [m in the end of the reply which I don't get when I use the Telnet client provided by windows.
Although this seems to be a very dump question but any ideas, comments, reviews because I have tried too many different solutions but I ended up with nothing.
Any recommendations for alternative telnet libraries are more than welcome.
- 08-03-2011, 02:47 AM #2
The [m thing is a VT220 control code. Actually it's preceded by the escape character, which doesn't have a printable representation. I wrote some Telnet/VT220 stuff recently for a MUD, and found that although Telnet and VT220 have different origins and a lot of functional overlap, most "Telnet" clients nowadays actually use a mishmash of the two protocols. A strict implementation of either probably won't do you much good for anything, except maybe connecting to an old teletype machine.
As for the delay: are you flushing your output stream after every write?
- 08-03-2011, 02:55 AM #3
Oh, and I'd be flattered if you gave my library a try. It contains a class called BogusNVT that provides very minimal functionality for communicating with "Telnet" devices. Basically I took a lot of shortcuts based on the assumption that it won't be talking with any real VT220s. There's a simple demo program in the demo package.
It occurred to me the other day that there might be a bug in my RegExpEatingReader, namely that I think it's eating the shortest match instead of the longest match... but that shouldn't affect the operation of BogusNVT.
Last edited by kjkrum; 08-03-2011 at 02:57 AM.
- 08-03-2011, 08:22 PM #4Member
- Join Date
- May 2010
- Rep Power
Thank you for reply helpful reply it makes a lot of sense now regarding the [m because the apache.commons.net.telnet library implements the telnet VT100 not the VT220.
I am flushing the output after each write as shown below:
I will try your library and inform you about the results.
Once again thank you for your information.
- 08-03-2011, 08:32 PM #5
A code like "escape[36m" should also be valid to a VT100 emulator. I don't think "escape[m" is valid in VT100, VT220, or ANSI X3.64, but I think some old BBS software started using it to mean "reset attributes", and it stuck around despite being non-standard. (The correct way to reset attributes is "escape[0m".)
- By blind melon in forum Advanced JavaReplies: 1Last Post: 12-05-2010, 06:25 AM
- By Kelly in forum Java ServletReplies: 1Last Post: 05-19-2010, 10:10 AM
- By turanan in forum New To JavaReplies: 0Last Post: 06-16-2009, 04:35 PM
- By jurka in forum NetworkingReplies: 0Last Post: 09-01-2008, 06:46 PM
- By JavaBean in forum Java SoftwareReplies: 0Last Post: 10-02-2007, 05:13 PM