webtorrent / bittorrent-protocol

Simple, robust, BitTorrent peer wire protocol implementation
https://webtorrent.io
MIT License
343 stars 71 forks source link

Getting odd error. #12

Closed FLYBYME closed 8 years ago

FLYBYME commented 8 years ago

Im playing around with the code but keep getting this error when i tell utorrent to connect.

192.168.1.10:2432
  bittorrent-protocol [6b84ad93] new wire +0ms
  bittorrent-protocol [6b84ad93] end +19s
  bittorrent-protocol [6b84ad93] got uninterested +1ms
  bittorrent-protocol [6b84ad93] got choke +1ms
destroy (error: socket close)
  bittorrent-protocol [6b84ad93] destroy +1ms
  bittorrent-protocol [6b84ad93] end +1ms
  bittorrent-protocol [6b84ad93] got uninterested +0ms
  bittorrent-protocol [6b84ad93] got choke +1ms
192.168.1.10:2435
  bittorrent-protocol [570342ee] new wire +41s
  bittorrent-protocol [570342ee] Error: wire not speaking BitTorrent protocol (♥??Q"!U??↨w~▬=0Kr???K??,??w??O#\h??*-??3??
?‼D+►p??-LW??A`?m${?,??I??????a??I
????Z?????\?a??g?B♦q???/??????p??????↑♣???3??E?y??????????G?!J??♥??F?_C??1?w???%??►L?vK???''\7????;?\z?`♂_) +2ms
  bittorrent-protocol [570342ee] end +1ms
  bittorrent-protocol [570342ee] got uninterested +0ms
  bittorrent-protocol [570342ee] got choke +1ms
destroy (error: socket close)
  bittorrent-protocol [570342ee] destroy +5ms
  bittorrent-protocol [570342ee] end +1ms
  bittorrent-protocol [570342ee] got uninterested +0ms
  bittorrent-protocol [570342ee] got choke +1ms
FLYBYME commented 8 years ago

This is the code im running.

//192.168.1.101:9879
var dhtPort = 20001
var serverPort = 9879

var Protocol = require('bittorrent-protocol')
var net = require('net')

net.createServer(function(socket) {
    var wire = new Protocol()

    // pipe to and from the protocol
    socket.pipe(wire).pipe(socket)

    wire.on('handshake', function(infoHash, peerId) {
    console.log('handshake')
    })

    wire.on('unchoke', function() {
        console.log('peer is no longer choking us: ' + wire.peerChoking)
    })
}).listen(serverPort);

The client im using is utorrent 2.2

More error:

bittorrent-protocol [7cfa097b] new wire +0ms
bittorrent-protocol [7cfa097b] Error: wire not speaking BitTorrent protocol (?!??♂??→?↨ ????§????m▬.¶??E;↨?&?♠?       "?_♫z??R????DU?]???h???♣►☼?♠??
.?}??$?@?Zv?8???V???_??IJ???§↑?5?u'?-{↑???y??.B????`??♣?e???kF2???l???k?c??k??L[?- A?1>??;6??2?[♂5?
?e??SC?5?∟?☺??n?
B?Fb????) +204ms
bittorrent-protocol [7cfa097b] end +4ms
bittorrent-protocol [7cfa097b] got uninterested +0ms
bittorrent-protocol [7cfa097b] got choke +1ms
bittorrent-protocol [e8e24ae6] new wire +48s
&It?↔F↓??B?|??I?↔?♂?n#U?R)?u?↨?F|? ) +2mse not speaking BitTorrent protocol (?????
bittorrent-protocol [e8e24ae6] end +1ms
bittorrent-protocol [e8e24ae6] got uninterested +0ms
bittorrent-protocol [e8e24ae6] got choke +1ms
``
feross commented 8 years ago

When you get the 'handshake' event, you need to immediately respond with a wire.handshake() back.

wire.on('handshake', function(infoHash, peerId) {
  wire.handshake(infoHash, myPeerId)
})