-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error - Unexpected end of stream #56
Comments
@DrDelay It's due the StreamWrapper. hmm, do you have any thought about it? |
I can't reproduce it at f70c9ce . I tried PlayerProfile and PokemonCount example, both worked. |
I'm using PTC auth, if that matters... Other than that, it's unmodified fresh code (git clone, composer install) at f70c9ce |
Weird, I could reproduce the problem. Reverted the pull request until we find out what's causing the problem. @jmcquillan Try the latest commit. |
e8d58cc works for me! |
What is your guys environment? |
Tried both PHP 7.0.3-13 ( NTS ) and PHP 7.0.9-1 ( NTS ). Same issue. What OS are you using? |
Windows 7, but I just tried it on a Debian Jessie with a |
I'm running Ubuntu 14.04. I love these sort of problems... :D |
The condition for the Exception is |
I was thinking the same, it's probably related to encoding. It usually is. |
|
en_US PHP 5.6.24 on Mac OS 10.11.6 with curl 7.43.0 |
The length of the string returned from stream_get_contents differs between the different streams. 94 (ProtobufIO::toStream) |
Regarding the mbstring that like I hastily said doesn't matter, I found a comment that says one should use |
If so and this means we'd have to force every user to use mbstring-ext, it may be reasonable to just pass it as a string as this works. I'd still like to figure out the reason of this error. |
Nice find, |
I'm kinda out of ideas then. I added this code to your unmarshall-method: // Unmarshall the response
echo mb_internal_encoding(), PHP_EOL;
echo mb_http_output(), PHP_EOL;
echo mb_http_input(), PHP_EOL;
echo mb_regex_encoding(), PHP_EOL;
$body = $response->getBody();
echo 'strlen(body->getContents): ', strlen($body->getContents()), PHP_EOL;
$body->seek(0);
echo 'body->getSize: ', $body->getSize(), PHP_EOL;
$body->seek(0);
$wrap = \GuzzleHttp\Psr7\StreamWrapper::getResource($body);
echo 'strlen(streamwrapped): ', strlen(stream_get_contents($wrap)), PHP_EOL;
$body->seek(0);
echo 'strlen(toStream): ', strlen(stream_get_contents(\ProtobufIO::toStream($response->getBody()->getContents()))), PHP_EOL;
die(); That results in:
I'm assuming you get different sizes. Maybe you could run that and see what encodings you get. |
Hmm, the problem disappeared after re-installing the dependencies. It could be a bug connected to Guzzle. Sorry for the late reply, been kind busy today. |
I got the same error with one of my accounts, however it works with my other account I get this on the working account:
and this on the one thats not working:
|
@finalpk Can you reproduce the problem in the latest version? |
With a fresh install, I tried to up RetrievePokemonCountExample.php (after updating the auth info) and get the error below:
PHP Fatal error: Uncaught exception 'Exception' with message 'read_bytes(): Unexpected end of stream' in vendor/nicklasw/pogoprotos-php/src/protocolbuffers.inc.php:364
This happens with many of the other example scripts as well.
The text was updated successfully, but these errors were encountered: