Results 1 to 5 of 5
Like Tree2Likes
  • 1 Post By kjkrum
  • 1 Post By kjkrum

Thread: Problem with apache.commons.telnet library

  1. #1
    mr_anderson is offline Member
    Join Date
    May 2010
    Location
    Florida
    Posts
    68
    Rep Power
    0

    Default Problem with apache.commons.telnet library

    Hi
    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.

    Best Regards.
    Anderson.

  2. #2
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default

    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?
    Get in the habit of using standard Java naming conventions!

  3. #3
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default

    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 01:57 AM.
    mr_anderson likes this.
    Get in the habit of using standard Java naming conventions!

  4. #4
    mr_anderson is offline Member
    Join Date
    May 2010
    Location
    Florida
    Posts
    68
    Rep Power
    0

    Default

    Dear Kjkrum
    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:

    out.write();
    out.fllush();

    I will try your library and inform you about the results.
    Once again thank you for your information.
    Regards.
    Anderson.

  5. #5
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default

    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".)
    mr_anderson likes this.
    Get in the habit of using standard Java naming conventions!

Similar Threads

  1. Apache Commons Math Transform library.
    By blind melon in forum Advanced Java
    Replies: 1
    Last Post: 12-05-2010, 05:25 AM
  2. Replies: 1
    Last Post: 05-19-2010, 09:10 AM
  3. Replies: 0
    Last Post: 06-16-2009, 03:35 PM
  4. Problems with ftp, commons library
    By jurka in forum Networking
    Replies: 0
    Last Post: 09-01-2008, 05:46 PM
  5. Commons Library Framework 0.8.0
    By JavaBean in forum Java Software
    Replies: 0
    Last Post: 10-02-2007, 04:13 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •