Skip to content

basic: endless loop on connection close in tcp_stream #36

Closed

Description

@compot-dev

In Decoder.tcp_stream() (branch basic):

int len = (input.read() << 8) | input.read();
...
while (read < len) {
    read += input.read(data, read, len - read);
}

InputStream.read() returns -1 at end of stream, and the result is never checked.

  • When the camera closes the connection while a packet is being read, read keeps decreasing by 1. The inner loop never ends and never checks activeStream, so the network thread hangs at 100% CPU and the app never reconnects.
  • At EOF the header read gives len = -1, so new byte[-1] throws NegativeArraySizeException.

Fix: check every read for -1 and throw IOException, so the outer loop reconnects.

Activity

  1. added
    bugSomething isn't working
    basicLegacy basic branch
    on Oct 12, 2026
  2. added a commit that references this issue on Oct 12, 2026
  3. compot-dev commented on Oct 12, 2026

    @compot-dev
    CollaboratorAuthor

    Fixed in #41 (merged into basic as 6cf68b5). Not closed automatically because basic is not the default branch.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    basicLegacy basic branchbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions