Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

did not return a complete response when it is too long #195

Open
VFagionato opened this issue May 14, 2021 · 2 comments
Open

did not return a complete response when it is too long #195

VFagionato opened this issue May 14, 2021 · 2 comments

Comments

@VFagionato
Copy link

VFagionato commented May 14, 2021

i using a telnet of routeviews.org.

I can connected and send a command to the telnet, but the response comes incomplete.

bellow is my configs and code.

//asNumber comes in the body of the request

let commandToTelnet = `sh ip bgp regex ${asNumber} json` 

let connection = new Telnet()

  let params= {
    host: "128.223.51.102",
    port: 23,
    timeout: 60000,
    pageSeparator: '--More--',
    negotiationMandatory: false,
    echoLines: 2000
  }

  try {
    await connection.connect(params)
    try {
      await connection.send(commandToTelnet, {timeout: 60000, maxBufferLength: 10000000}, (error, response) => {
        if (error) console.log(error)
  
        return res.status(200).send(response)
      })
    } catch(error) {
      console.log(error)
    }
  } catch(error) {
    console.log(error)
  }

and the response is:

Hello, this is FRRouting (version 7.3-rv). Copyright 1996-2005 Kunihiro Ishiguro, et al. ��������"���route-views2.routeviews.org> sh ip bgp regex 262481 json { "vrfId": 0, "vrfName": "default", "tableVersion": 155297554, "routerId": "128.223.51.102", "defaultLocPrf": 100, "localAS": 6447, "routes": { "45.160.88.0/22": [ { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"105.16.0.247", "aspath":"37100 3356 53062 262481", "path":"37100 3356 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"105.16.0.247", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"217.192.89.50", "aspath":"3303 3356 53062 262481", "path":"3303 3356 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"217.192.89.50", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"212.66.96.126", "aspath":"20912 3257 3356 53062 262481", "path":"20912 3257 3356 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"212.66.96.126", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"202.93.8.242", "aspath":"24441 3491 3491 174 53062 262481", "path":"24441 3491 3491 174 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"202.93.8.242", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"206.24.210.80", "aspath":"3561 209 3356 53062 262481", "path":"3561 209 3356 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"206.24.210.80", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"91.228.151.1", "aspath":"31019 262589 53062 262481", "path":"31019 262589 53062 262481", "origin":"incomplete", "nexthops":[ { "ip":"91.228.151.1", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"137.164.16.84", "aspath":"2152 3356 53062 262481", "path":"2152 3356 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"137.164.16.84", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"96.4.0.55", "aspath":"11686 262589 53062 262481", "path":"11686 262589 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"96.4.0.55", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"203.62.252.83", "aspath":"1221 4637 3356 53062 262481", "path":"1221 4637 3356 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"203.62.252.83", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"168.209.255.56", "aspath":"3741 3356 53062 262481", "path":"3741 3356 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"168.209.255.56", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "med":2001, "metric":2001, "weight":0, "peerId":"129.250.1.71", "aspath":"2914 3356 53062 262481", "path":"2914 3356 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"129.250.1.71", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"147.28.7.1", "aspath":"3130 2914 3356 53062 262481", "path":"3130 2914 3356 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"147.28.7.1", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "med":1, "metric":1, "weight":0, "peerId":"198.129.33.85", "aspath":"293 3356 53062 262481", "path":"293 3356 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"198.129.33.85", "afi":"ipv4", "used":true } ] }, { "valid":true, "bestpath":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"87.121.64.4", "aspath":"57463 262481", "path":"57463 262481", "origin":"IGP", "nexthops":[ { "ip":"87.121.64.4", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "med":1026, "metric":1026, "weight":0, "peerId":"194.153.0.253", "aspath":"5413 3356 53062 262481", "path":"5413 3356 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"194.153.0.253", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"137.39.3.55", "aspath":"701 3356 53062 262481", "path":"701 3356 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"137.39.3.55", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"195.208.112.161", "aspath":"3277 3267 174 53062 262481", "path":"3277 3267 174 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"195.208.112.161", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "med":0, "metric":0, "weight":0, "peerId":"134.222.87.1", "aspath":"286 3257 174 53062 262481", "path":"286 3257 174 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"134.222.87.1", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"202.232.0.3", "aspath":"2497 3356 53062 262481", "path":"2497 3356 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"202.232.0.3", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"203.189.128.233", "aspath":"23673 3491 174 53062 262481", "path":"23673 3491 174 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"203.189.128.233", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "med":14275, "metric":14275, "weight":0, "peerId":"208.51.134.255", "aspath":"3549 267469 262481", "path":"3549 267469 262481", "origin":"IGP", "nexthops":[ { "ip":"208.51.134.255", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"203.181.248.168", "aspath":"7660 2516 6762 53062 262481", "path":"7660 2516 6762 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"203.181.248.168", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"85.114.0.217", "aspath":"8492 9002 6762 53062 262481", "path":"8492 9002 6762 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"85.114.0.217", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"202.73.40.45", "aspath":"18106 262589 53062 262481", "path":"18106 262589 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"202.73.40.45", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "med":10, "metric":10, "weight":0, "peerId":"89.149.178.10", "aspath":"3257 3356 53062 262481", "path":"3257 3356 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"89.149.178.10", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"198.58.198.252", "aspath":"1403 174 53062 262481", "path":"1403 174 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"198.58.198.252", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"12.0.1.63", "aspath":"7018 3356 53062 262481", "path":"7018 3356 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"12.0.1.63", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"162.251.163.2", "aspath":"53767 14315 14315 6453 3356 53062 262481", "path":"53767 14315 14315 6453 3356 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"162.251.163.2", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "med":0, "metric":0, "weight":0, "peerId":"91.218.184.60", "aspath":"49788 174 53062 262481", "path":"49788 174 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"91.218.184.60", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "med":0, "metric":0, "weight":0, "peerId":"37.139.139.17", "aspath":"57866 1299 6762 53062 262481", "path":"57866 1299 6762 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"37.139.139.17", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "med":0, "metric":0, "weight":0, "peerId":"147.28.7.2", "aspath":"3130 1239 3356 53062 262481", "path":"3130 1239 3356 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"147.28.7.2", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"45.61.0.85", "aspath":"22652 174 53062 262481", "path":"22652 174 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"45.61.0.85", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"62.115.129.4", "aspath":"1299 3356 53062 262481", "path":"1299 3356 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"62.115.129.4", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"140.192.8.16", "aspath":"20130 6939 267469 262481", "path":"20130 6939 267469 262481", "origin":"IGP", "nexthops":[ { "ip":"140.192.8.16", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "med":24577, "metric":24577, "weight":0, "peerId":"208.51.134.246", "aspath":"3549 267469 262481", "path":"3549 267469 262481", "origin":"IGP", "nexthops":[ { "ip":"208.51.134.246", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "weight":0, "peerId":"64.71.137.241", "aspath":"6939 267469 262481", "path":"6939 267469 262481", "origin":"IGP", "nexthops":[ { "ip":"64.71.137.241", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":22, "network":"45.160.88.0\/22", "med":0, "metric":0, "weight":0, "peerId":"94.156.252.18", "aspath":"34224 3356 53062 262481", "path":"34224 3356 53062 262481", "origin":"IGP", "nexthops":[ { "ip":"94.156.252.18", "afi":"ipv4", "used":true } ] } ],"45.160.88.0/24": [ { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"105.16.0.247", "aspath":"37100 3356 3549 262481", "path":"37100 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"105.16.0.247", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"147.28.7.1", "aspath":"3130 2914 3356 3549 262481", "path":"3130 2914 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"147.28.7.1", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "med":2, "metric":2, "weight":0, "peerId":"147.28.7.2", "aspath":"3130 2914 3356 3549 262481", "path":"3130 2914 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"147.28.7.2", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"217.192.89.50", "aspath":"3303 3356 3549 262481", "path":"3303 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"217.192.89.50", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"212.66.96.126", "aspath":"20912 3257 3356 3549 262481", "path":"20912 3257 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"212.66.96.126", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"202.93.8.242", "aspath":"24441 3491 3491 3356 3549 262481", "path":"24441 3491 3491 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"202.93.8.242", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"206.24.210.80", "aspath":"3561 209 3356 3549 262481", "path":"3561 209 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"206.24.210.80", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"137.164.16.84", "aspath":"2152 3356 3549 262481", "path":"2152 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"137.164.16.84", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"203.62.252.83", "aspath":"1221 4637 3356 3549 262481", "path":"1221 4637 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"203.62.252.83", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "med":2001, "metric":2001, "weight":0, "peerId":"129.250.1.71", "aspath":"2914 3356 3549 262481", "path":"2914 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"129.250.1.71", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"168.209.255.56", "aspath":"3741 3356 3549 262481", "path":"3741 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"168.209.255.56", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "med":1026, "metric":1026, "weight":0, "peerId":"194.153.0.253", "aspath":"5413 3356 3549 262481", "path":"5413 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"194.153.0.253", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "med":1, "metric":1, "weight":0, "peerId":"198.129.33.85", "aspath":"293 3356 3549 262481", "path":"293 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"198.129.33.85", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"195.208.112.161", "aspath":"3277 3267 3356 3549 262481", "path":"3277 3267 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"195.208.112.161", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"202.232.0.3", "aspath":"2497 3356 3549 262481", "path":"2497 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"202.232.0.3", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"137.39.3.55", "aspath":"701 3356 3549 262481", "path":"701 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"137.39.3.55", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"203.189.128.233", "aspath":"23673 3491 3356 3549 262481", "path":"23673 3491 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"203.189.128.233", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "med":14185, "metric":14185, "weight":0, "peerId":"208.51.134.255", "aspath":"3549 262481", "path":"3549 262481", "origin":"IGP", "nexthops":[ { "ip":"208.51.134.255", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"91.228.151.1", "aspath":"31019 39326 1299 3356 3549 262481", "path":"31019 39326 1299 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"91.228.151.1", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "med":0, "metric":0, "weight":0, "peerId":"134.222.87.1", "aspath":"286 3257 3356 3549 262481", "path":"286 3257 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"134.222.87.1", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"96.4.0.55", "aspath":"11686 3356 3549 262481", "path":"11686 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"96.4.0.55", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"85.114.0.217", "aspath":"8492 9002 3356 3549 262481", "path":"8492 9002 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"85.114.0.217", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"202.73.40.45", "aspath":"18106 6939 3356 3549 262481", "path":"18106 6939 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"202.73.40.45", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"198.58.198.252", "aspath":"1403 6453 3356 3549 262481", "path":"1403 6453 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"198.58.198.252", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"203.181.248.168", "aspath":"7660 2516 3356 3549 262481", "path":"7660 2516 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"203.181.248.168", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"45.61.0.85", "aspath":"22652 6453 3356 3549 262481", "path":"22652 6453 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"45.61.0.85", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"12.0.1.63", "aspath":"7018 3356 3549 262481", "path":"7018 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"12.0.1.63", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "med":10, "metric":10, "weight":0, "peerId":"89.149.178.10", "aspath":"3257 3356 3549 262481", "path":"3257 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"89.149.178.10", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"162.251.163.2", "aspath":"53767 14315 14315 6453 3356 3549 262481", "path":"53767 14315 14315 6453 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"162.251.163.2", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"91.218.184.60", "aspath":"49788 1299 3356 3549 262481", "path":"49788 1299 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"91.218.184.60", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"62.115.129.4", "aspath":"1299 3356 3549 262481", "path":"1299 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"62.115.129.4", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "med":0, "metric":0, "weight":0, "peerId":"37.139.139.17", "aspath":"57866 1299 3356 3549 262481", "path":"57866 1299 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"37.139.139.17", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"140.192.8.16", "aspath":"20130 6939 3356 3549 262481", "path":"20130 6939 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"140.192.8.16", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "med":0, "metric":0, "weight":0, "peerId":"94.156.252.18", "aspath":"34224 3356 3549 262481", "path":"34224 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"94.156.252.18", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"64.71.137.241", "aspath":"6939 3356 3549 262481", "path":"6939 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"64.71.137.241", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "med":24487, "metric":24487, "weight":0, "peerId":"208.51.134.246", "aspath":"3549 262481", "path":"3549 262481", "origin":"IGP", "nexthops":[ { "ip":"208.51.134.246", "afi":"ipv4", "used":true } ] }, { "valid":true, "bestpath":true, "pathFrom":"external", "prefix":"45.160.88.0", "prefixLen":24, "network":"45.160.88.0\/24", "weight":0, "peerId":"87.121.64.4", "aspath":"57463 262481", "path":"57463 262481", "origin":"IGP", "nexthops":[ { "ip":"87.121.64.4", "afi":"ipv4", "used":true } ] } ],"45.160.89.0/24": [ { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "weight":0, "peerId":"105.16.0.247", "aspath":"37100 3356 3549 262481", "path":"37100 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"105.16.0.247", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "weight":0, "peerId":"147.28.7.1", "aspath":"3130 2914 3356 3549 262481", "path":"3130 2914 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"147.28.7.1", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "med":2, "metric":2, "weight":0, "peerId":"147.28.7.2", "aspath":"3130 2914 3356 3549 262481", "path":"3130 2914 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"147.28.7.2", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "weight":0, "peerId":"217.192.89.50", "aspath":"3303 3356 3549 262481", "path":"3303 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"217.192.89.50", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "weight":0, "peerId":"212.66.96.126", "aspath":"20912 3257 3356 3549 262481", "path":"20912 3257 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"212.66.96.126", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "weight":0, "peerId":"202.93.8.242", "aspath":"24441 3491 3491 3356 3549 262481", "path":"24441 3491 3491 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"202.93.8.242", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "weight":0, "peerId":"206.24.210.80", "aspath":"3561 209 3356 3549 262481", "path":"3561 209 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"206.24.210.80", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "weight":0, "peerId":"137.164.16.84", "aspath":"2152 3356 3549 262481", "path":"2152 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"137.164.16.84", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "weight":0, "peerId":"203.62.252.83", "aspath":"1221 4637 3356 3549 262481", "path":"1221 4637 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"203.62.252.83", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "med":2001, "metric":2001, "weight":0, "peerId":"129.250.1.71", "aspath":"2914 3356 3549 262481", "path":"2914 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"129.250.1.71", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "weight":0, "peerId":"168.209.255.56", "aspath":"3741 3356 3549 262481", "path":"3741 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"168.209.255.56", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "med":1026, "metric":1026, "weight":0, "peerId":"194.153.0.253", "aspath":"5413 3356 3549 262481", "path":"5413 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"194.153.0.253", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "med":1, "metric":1, "weight":0, "peerId":"198.129.33.85", "aspath":"293 3356 3549 262481", "path":"293 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"198.129.33.85", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "weight":0, "peerId":"195.208.112.161", "aspath":"3277 3267 3356 3549 262481", "path":"3277 3267 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"195.208.112.161", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "weight":0, "peerId":"202.232.0.3", "aspath":"2497 3356 3549 262481", "path":"2497 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"202.232.0.3", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "weight":0, "peerId":"137.39.3.55", "aspath":"701 3356 3549 262481", "path":"701 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"137.39.3.55", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "weight":0, "peerId":"203.189.128.233", "aspath":"23673 3491 3356 3549 262481", "path":"23673 3491 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"203.189.128.233", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "med":14185, "metric":14185, "weight":0, "peerId":"208.51.134.255", "aspath":"3549 262481", "path":"3549 262481", "origin":"IGP", "nexthops":[ { "ip":"208.51.134.255", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "weight":0, "peerId":"91.228.151.1", "aspath":"31019 39326 1299 3356 3549 262481", "path":"31019 39326 1299 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"91.228.151.1", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "med":0, "metric":0, "weight":0, "peerId":"134.222.87.1", "aspath":"286 3257 3356 3549 262481", "path":"286 3257 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"134.222.87.1", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "weight":0, "peerId":"96.4.0.55", "aspath":"11686 3356 3549 262481", "path":"11686 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"96.4.0.55", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "weight":0, "peerId":"85.114.0.217", "aspath":"8492 9002 3356 3549 262481", "path":"8492 9002 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"85.114.0.217", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "weight":0, "peerId":"202.73.40.45", "aspath":"18106 6939 3356 3549 262481", "path":"18106 6939 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"202.73.40.45", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "weight":0, "peerId":"198.58.198.252", "aspath":"1403 6453 3356 3549 262481", "path":"1403 6453 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"198.58.198.252", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "weight":0, "peerId":"203.181.248.168", "aspath":"7660 2516 3356 3549 262481", "path":"7660 2516 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"203.181.248.168", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "weight":0, "peerId":"45.61.0.85", "aspath":"22652 6453 3356 3549 262481", "path":"22652 6453 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"45.61.0.85", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "weight":0, "peerId":"12.0.1.63", "aspath":"7018 3356 3549 262481", "path":"7018 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"12.0.1.63", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "med":10, "metric":10, "weight":0, "peerId":"89.149.178.10", "aspath":"3257 3356 3549 262481", "path":"3257 3356 3549 262481", "origin":"IGP", "nexthops":[ { "ip":"89.149.178.10", "afi":"ipv4", "used":true } ] }, { "valid":true, "pathFrom":"external", "prefix":"45.160.89.0", "prefixLen":24, "network":"45.160.89.0\/24", "weight":0, "peerId":"162.251.163.2", "aspath

In addition to showing the welcome message on the return, it does not show me the full json that telnet returns.

The json is quite large, but I need it complete for my application

Am I doing something wrong?

@mariavillosa
Copy link

mariavillosa commented Nov 16, 2021

I have kind of a similar problem. When running the following code:

const Telnet = require('telnet-client');

const code = `
perl << 'EEOF' | sed 's/^/...OUTPUTBEGIN /'
#!/usr/bin/perl -w
use strict;
use 5.10.0;

my $count  = 0;
my $physc  = 0;
my $entc   = 0;
my $used   = -1;
my $smtVal;
my $lcpuVal;
my %config    = ();
my %paraIndex = ();

my $vmstat = \`vmstat -t 15 1|tail -1\`;
my @temp   = split / +/, $vmstat;
my $idle   = $temp[-4];
$used = 100 - $idle;

if ( $used == -1 ) {
    print "CPU_Usage: match_error\n";
    print \`echo EOF\`;
}
else {
    $used = sprintf "%.2f", $used;
    print "CPU_Usage: $used\n";
    print \`echo EOF\`;
}

EEOF
echo definiteend
exit
`;

const cfg = {
  host: '127.0.0.1',
  port: 23,
  username: 'fakeuser',
  password: 'fakepass',
  shellPrompt: '$',
  removeEcho: 100,
  debug: true,
  timeout: 5000
};

(async (cfg) => {
  const telnet = new TelnetConnection();
  await telnet.connect(cfg);
  console.log(await telnet.exec(code));
})(cfg);

Sometimes it will print out the correct output:

ok@pop-os:~/Code/Upwork/ssh2_api$ node telnetExample.js 

/'
#!/usr/bin/perl -w
use strict;
use 5.10.0;

my $count  = 0;
my $physc  = 0;
my $entc   = 0;
my $used   = -1;
my $smtVal;
my $lcpuVal;
my %config    = ();
my %paraIndex = ();

my $vmstat = `vmstat -t 15 1$ |tail -1`;
my @temp   = split / +/, $vmstat;
my $idle   = $temp[-4];
$used = 100 - $idle;

if ( $used == -1 ) {
    print "CPU_Usage: match_error\n";
    print `echo EOF`;
}
else {
    $used = sprintf "%.2f", $used;
    print "CPU_Usage> : $used\n";
    print `echo EOF`;
}

EEOF
echo definiteend
exit
    
CPU_Usage: 100.00
EOF
$ definiteend

Other times, it will cut off and just display the input I sent it:

ok@pop-os:~/Code/Upwork//ssh2_api$ node telnetExample.js 

/'
#!/usr/bin/perl -w
use strict;
use 5.10.0;

my $count  = 0;
my $physc  = 0;
my $entc   = 0;
my $used   = -1;
my $smtVal;
my $lcpuVal;
my %config    = ();
my %paraIndex = ();

my $vmstat = `vmstat -t 15 1|tail -1`;
my @temp   = split / +/, $vmstat;
my $idle   = $temp[-4];
$used = 100 - $idle;

if ( $used == -1 ) {
    print "CPU_Usage: match_error\n";
    print `echo EOF`;
}
else {
    $used = sprintf "%.2f",$  $used;
    print "CPU_Usage: $used\n";
    print `echo EOF`;
}

EEOF
echo definiteend
exit

It's about 50/50 which happens, and I have no idea what's changing when it works or not and how I can make it always work.

@zxdong262
Copy link

could try this:

let params= {
    host: "128.223.51.102",
    port: 23,
    timeout: 60000,
    pageSeparator: '--More--',
    negotiationMandatory: false,
    echoLines: 2000,
    socketConnectOptions: {
      highWaterMark: 64 * 1024 * 16
    }
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants