V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
CupTools
V2EX  ›  Node.js

为什么 nodejs net.connect() 会 read ECONNRESET,然而 telnet 就没有问题

  •  
  •   CupTools · Apr 13, 2017 · 4982 views
    This topic created in 3314 days ago, the information mentioned may be changed or developed.

    如题

    var client = net.connect(43, server, function() {
        client.write(domain + '\n', 'ascii')
    })
    

    yields

    { Error: read ECONNRESET
        at exports._errnoException (util.js:1050:11)
        at TCP.onread (net.js:581:26) code: 'ECONNRESET', errno: 'ECONNRESET', syscall: 'read' }
    

    However,

    telnet xxxx 43
    

    yields

    telnet xxx 43
    Trying xxx...
    Connected to xxx.
    Escape character is '^]'.
    
    4 replies    2017-04-16 22:14:13 +08:00
    fds
        1
    fds  
       Apr 13, 2017
    telnet 没写东西呀。为了一致,把 client.write() 删掉试试?
    CupTools
        2
    CupTools  
    OP
       Apr 13, 2017 via Android
    @fds telnet 是有写东西的 没放出来
    CupTools
        3
    CupTools  
    OP
       Apr 14, 2017
    😂 找到问题了 要'\r\n'不是'\n'
    polun
        4
    polun  
       Apr 16, 2017
    用`os.EOL`?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3029 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 35ms · UTC 15:14 · PVG 23:14 · LAX 08:14 · JFK 11:14
    ♥ Do have faith in what you're doing.