Skip to content
This repository has been archived by the owner on Sep 20, 2021. It is now read-only.

stream_socket_recvfrom returning false #56

Closed
atrope opened this issue Mar 18, 2019 · 4 comments
Closed

stream_socket_recvfrom returning false #56

atrope opened this issue Mar 18, 2019 · 4 comments

Comments

@atrope
Copy link

atrope commented Mar 18, 2019

Hello,
As i am using HOA in bref's AWS Lambda Layer, i am getting to an error that
stream_socket_recvfrom is returning false on /hoa/socket/Connection/Connection.php .

The same request can randomly do that, and when it does, it never recovers.

I've found this thread from 2011: https://bugs.php.net/bug.php?id=55814
it is from Ivan from Hoa Project :)

There it is saying that if we set the stream_set_blocking($client, true); it should work.

I did that and edited the part that deals with this on our case:

        if (false === $this->isRemoteAddressConsidered()) {
            stream_set_blocking($this->getStream(), true);
            return stream_socket_recvfrom($this->getStream(), $length, $flags);
        }

And still is returning us false, and all subsequent requests also return false.

The client is reporting to still be connected even with the falses, and write is returning the correct number of bytes written.

Maybe you have something that i didn't think of?

Thanks

@Pierozi
Copy link
Member

Pierozi commented Mar 18, 2019

I've got some pretty similar issue when dealing with the WebSocket implementation (but not in Lambda context).
I have old PR #53 related, but dunno if that can solve your issue, it's been almost 3 years i've change that.

ping @Hywan Socket/WebSocket really need some focus for php7.1+ migration

@atrope
Copy link
Author

atrope commented Mar 18, 2019

@Pierozi are you making a loop until it has data? and it works although it first returned false?

something like this?

do{
$data = stream_socket_recvfrom($this->getStream(), $length, $flags);
}while($data === false);
  return $data

By the way... PHP 7.2

@Pierozi
Copy link
Member

Pierozi commented Mar 19, 2019

Kinda, if the blocked mode are enabled, i'm reading in loop until buffer end or false return. (and use fread instead if encrypted mode enable)
In your side you should be able to implement re-connection, read instead of end up with error.

@atrope
Copy link
Author

atrope commented Mar 20, 2019

@Pierozi I tried an equivalent solution and i was getting a lot of timeouts(because the process was stuck in the loop trying to read N Bytes forever.

@Hywan do you think in anything i could try?

Thanks

@atrope atrope closed this as completed Mar 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

2 participants