Skip to content
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

Fatal Error in RequestHandler class with emulator without GRPC extension #7187

Open
mrVrAlex opened this issue Mar 27, 2024 · 4 comments
Open
Assignees

Comments

@mrVrAlex
Copy link

Hi

Any Client API (for example PubSub) can not work with emulator without grpc extension.
When we put in clientConfig 'emulatorHost' & 'hasEmulator' keys (PubSub client set it when exist PUBSUB_EMULATOR_HOST env)
then it config passing to RequestHandler constructor and using here

if ((bool) $clientConfig['emulatorHost']) {

And there call $this->emulatorGapicConfig function which part of EmulatorTrait
https://github.com/googleapis/google-cloud-php/blob/main/Core/src/EmulatorTrait.php#L44

And without any conditions code try build array config with call
\Grpc\ChannelCredentials::createInsecure() which part of GRPC extension.

In result:

Fatal error: Uncaught Error: Class "Grpc\ChannelCredentials" not found in /app/vendor/google/cloud-core/src/EmulatorTrait.php:44
Stack trace:
#0 /app/vendor/google/cloud-core/src/RequestHandler.php(72): Google\Cloud\Core\RequestHandler->emulatorGapicConfig('pubsub:8681')
#1 /app/vendor/google/cloud-pubsub/src/PubSubClient.php(215): Google\Cloud\Core\RequestHandler->__construct(Object(Google\ApiCore\Serializer), Array, Array)

Another (maybe related) issue when try avoid Fatal error with stub class & method for ChannelCredentials and put in config
['transport' => 'resr']
then I got different error:

In CurlFactory.php line 210:
                                                                               
  [GuzzleHttp\Exception\ConnectException]                                      
  cURL error 35: OpenSSL/3.1.4: error:0A00010B:SSL routines::wrong version nu  
  mber (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://p  
  ubsub:8681/v1/projects/emulator-project/topics/local.esbNew:publish?%24alt=  
  json%3Benum-encoding%3Dint  

Because client by some reason choose HTTPS schema instead of HTTP and emulator don't work with SSL...

So this is bug?

Environment details

  • OS: ANY
  • PHP version: ANY
  • Package name and version: PubSub 2.0

Steps to reproduce

  1. take official docker php image
  2. run emulator
  3. run code in example

Code example

putenv('PUBSUB_EMULATOR_HOST=localhost:8900');
$pubsub = new PubSubClient(['projectId' => 'my-project']);
@bshaffer
Copy link
Contributor

bshaffer commented Apr 3, 2024

Hello! Thank you for commenting on this. Does it work when you install the grpc extension for PHP? If so, I suggest doing this.

In the meantime, if the emulator requires gRPC, we should wrap the EmulatorTrait to check if grpc is installed, and throw an exception if it isn't.

@mrVrAlex
Copy link
Author

mrVrAlex commented Apr 9, 2024

Yes with gRPC extension it is worked properly.
But if google/cloud-pubsub v2.x and others (which depends on new EmulatorTrait) not works with emulators via http protocol - then it is major breaking changes?
Maybe this should reflect in changelog & documentation?
(BTW: in our case we can not use grpc extension in PHP because it conflict with swoole / openswoole extension)

@bshaffer
Copy link
Contributor

bshaffer commented May 6, 2024

(BTW: in our case we can not use grpc extension in PHP because it conflict with swoole / openswoole extension)

Can you elaborate more on this? This is news to me, and it's something we should file as a bug in the grpc repo to get fixed.

@bshaffer
Copy link
Contributor

bshaffer commented May 6, 2024

@mrVrAlex

it is major breaking changes?

No, because the emulators have never worked with REST, only with gRPC. To confirm this, I checked out v0.233.0 (which is the same as google/cloud-pubsub:v1.51.1, the last release before 2.0), and used composer install --prefer-lowest, and received the same error you have here. So AFAICT, REST has never worked in the emulator... there does not seem to be any regression here.

We could open this as a feature request against gcloud, but otherwise this is out of our (the client library team's) hands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants