amphp / amp

A non-blocking concurrency framework for PHP applications. 🐘
https://amphp.org/amp
MIT License
4.24k stars 257 forks source link

EvLoop::io(): 9 bytes of buffered data lost during stream conversion! #350

Open PNixx opened 3 years ago

PNixx commented 3 years ago
EvLoop::io(): 9 bytes of buffered data lost during stream conversion!, /home/shared/vendor/amphp/amp/lib/Loop/EvDriver.php:253
$ pecl list
Installed packages, channel pecl.php.net:
=========================================
Package Version State
ev      1.1.2   stable
pq      2.1.8   stable
raphf   2.0.1   stable
kelunik commented 3 years ago

I guess we need more information to reproduce this behavior. Do you have a minimal script to show such behavior?

PNixx commented 3 years ago

No, I use amphp cluster and rabbit with Prefetch count = 30. Ev lib not stable working, I change it to Uv lib.

kelunik commented 3 years ago

This is a generic error when casting PHP streams internally in the extension. Which stream is this warning emitted for? Something in a library or your own code?

https://github.com/php/php-src/blob/01b3fc03c30c6cb85038250bb5640be3a09c6a32/main/streams/cast.c#L326

PNixx commented 3 years ago

In only EvDriver

kelunik commented 3 years ago

I'm aware. But could you add an error handler that logs a stack trace for the warning, please?

bileslav commented 2 years ago

@kelunik, I also regularly come across this warning in my application. It's something in the library. How can I help find the cause? How can I catch the stack trace you mentioned?

[19-Jun-2022 15:34:59 Europe/Moscow] PHP Warning:  EvLoop::io(): 13 bytes of buffered data lost during stream conversion! in .../vendor/amphp/amp/lib/Loop/EvDriver.php on line 260
kelunik commented 2 years ago

You have to set a global error handler and log the trace there / turn it into an exception.

bileslav commented 2 years ago

After dropping some dependencies (also dropped ev itself, but a bit later), I stopped getting the warning. Will come back if I run into it again.

VictorGSoutoXP commented 1 year ago

Esse erro ocorre quando dados foram perdidos durante a conversão do fluxo de dados em um formato que pode ser manipulado pelo PHP. Isso pode acontecer quando o driver de loop utilizado pelo AMP, neste caso o EvDriver, não é compatível com o fluxo de dados sendo usado. Para resolver esse erro, você pode tentar atualizar a versão do amphp/amp para a versão mais recente, que pode ter corrigido esse problema ou verificar se há atualizações para o EvDriver que solucionem esse problema. Outra opção é verificar se as extensões PHP ev e raphf estão instaladas e funcionando corretamente. Para isso, você pode executar o comando php -m no terminal para listar todas as extensões PHP instaladas. Se as extensões não estiverem instaladas, você pode instalá-las usando o gerenciador de pacotes PECL:

pecl install ev pecl install raphf

Certifique-se de que as versões instaladas dessas extensões sejam compatíveis com a versão do PHP que você está usando. Se as extensões já estiverem instaladas, verifique se elas estão habilitadas no arquivo de configuração do PHP. Você pode verificar a localização do arquivo de configuração do PHP executando o comando php --ini no terminal e verificar se as extensões estão habilitadas na seção ;extension= do arquivo de configuração. Se nenhuma dessas soluções resolver o problema, você pode tentar usar um driver de loop diferente no AMP, como o LibeventDriver, que é compatível com uma variedade de fluxos de dados e pode ser uma alternativa mais estável ao EvDriver.