amphp / byte-stream

A non-blocking stream abstraction for PHP based on Amp.

Home Page:https://amphp.org/byte-stream

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Problem writing to stream

prolic opened this issue · comments

I see this in my logs:

Amp\ByteStream\StreamException
Failed to write to stream after multiple attempts; fwrite(): send of 7302 bytes failed with errno=32 Broken pipe

This happens like every few seconds, I can try to provide a reproducible script, but that may take some time (currently on a business trip).

But I thought maybe you have an idea what to check.

Thing is, I still receive data from the stream after the error.

Looking into the implementation details of ResourceOutputStream I see feof i used during write. Not sure if my idea makes sense to you:
If the server constantly sends me data and in between my client (using amphp) sends something back (ack, nack f.e.), then the stream may not be at end of file, because the server is already sending new data again.

Either you still have data buffered in the read buffer or the socket you're writing to is half-closed.

The ResourceOutputStream reacts to Loop::onWritable - so what can I do about having data in the read buffer? Is it my fault?
Also half-closed stream - well that's my problem, I don't know why this happens.

@prolic Well, you can read that data to empty the buffer, but is that data an issue? I'm not sure I understand what your actual question is.

Ok, I'll close this issue for now and reopen if I have a reproducible test-script. Thanks for your input.