Coder Social home page Coder Social logo

pieces's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pieces's Issues

Freeze on startup due to invalid handshake?

As documented, the client sometimes freezes upon startup; I tried to debug this and managed to root out the cause.

In a nutshell, we're running into an infinite loop trying to parse the handshake response:

  async def _handshake(self):
        """
        Send the initial handshake to the remote peer and wait for the peer
        to respond with its handshake.
        """
        self.writer.write(Handshake(self.info_hash, self.peer_id).encode())
        await self.writer.drain()

        buf = b''
        while len(buf) < Handshake.length:
            buf = await self.reader.read(PeerStreamIterator.CHUNK_SIZE)

When debugging, I noticed that the len(buf) stays at 0 at all times during the occasional freeze, thus creating the infinite loop. I'm not entirely surely if it's a problem with our parsing methods, or if the handshake from that one peer was indeed invalid.

That said, I think we can easily mitigate this issue by hardcoding a retry limit. I've attempted a fix in #2 in conjunction with main feature in that PR, and things seemed to work fine (i.e, we can download a torrent without freezing).

Download error occured,help wanted

Dear eliasson:

I have recently been learning how to implement a P2P client through your blog and GitHub repo. However, I encountered numerous network issues when testing the downloads. I have browsed through many answers on Stack Overflow and even used ChatGPT, but none of them resolved the issue. So, I cloned your code and attempted to download the 'ubuntu' file in the 'tests' directory. Unfortunately, I faced the same problems. During the file download process, I encountered the following error messages:

1. ConnectionError: Unable to connect to tracker: status code 502
2. ConnectionError: Unable to connect to tracker: d14:failure reason63:Requested download is not authorized for use with this tracker.e
3. OSError: [WinError 121] The timeout for the semaphore has expired.
4. async for message in PeerStreamIterator(self.reader, buffer):
    TypeError: 'async for' received an object from __aiter__ that does not implement __anext__: coroutine

Have you encountered such an issue while implementing it? If you have, how did you resolve it? I would greatly appreciate any insights you can provide.

English is not my native language, if there is any offsen,please forgive me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.