Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

TypeError: strrpos(): Argument #1 ($haystack) must be of type string, bool given in /apps/notify_push/lib/SelfTest.php:197 #154

Closed
solracsf opened this issue Jan 18, 2022 · 6 comments
Labels
bug Something isn't working

Comments

@solracsf
Copy link
Member

Nextcloud 22.2.3.

./occ notify_push:self-test

✓ redis is configured
✓ push server is receiving redis messages
✓ push server can load mount info from database
✓ push server can connect to the Nextcloud server
✓ push server is a trusted proxy
An unhandled exception has been thrown:
TypeError: strrpos(): Argument #1 ($haystack) must be of type string, bool given in /apps/notify_push/lib/SelfTest.php:197
Stack trace:
#0 /apps/notify_push/lib/SelfTest.php(197): strrpos()
#1 /apps/notify_push/lib/Command/SelfTest.php(61): OCA\NotifyPush\SelfTest->test()
#2 /3rdparty/symfony/console/Command/Command.php(255): OCA\NotifyPush\Command\SelfTest->execute()
#3 /3rdparty/symfony/console/Application.php(1009): Symfony\Component\Console\Command\Command->run()
#4 /3rdparty/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand()
#5 /3rdparty/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun()
#6 /lib/private/Console/Application.php(209): Symfony\Component\Console\Application->run()
#7 /console.php(99): OC\Console\Application->run()
#8 /occ(11): require_once('...')
#9 {main}
@solracsf solracsf added the bug Something isn't working label Jan 18, 2022
@DrZoidberg09
Copy link

Same here with 23.0.4

@francoisPE
Copy link

francoisPE commented Sep 4, 2022

Same with nc 24.0.4 and notify_push 0.4.0 when running manual setup ./occ notify_push:setup https://mync.tld/push

concerned code line (/apps/notify_push/lib/SelfTest.php:197) is
$binaryVersionNoMinor = substr($binaryVersion, 0, strrpos($binaryVersion, '.'));

$binaryVersion is empty !
I remove lines in code corresponding to binary/app version test and it works !
$binaryVersion = $this->queue->getConnection()->get("notify_push_version");
is giving an empty value

                // test that the binary is up to date
                try {
                        $this->queue->getConnection()->del("notify_push_version");
                        $response = $this->client->post($server . '/test/version', ['nextcloud' => ['allow_local_address' => true], 'verify' => false]);
                        if ($response === "error") {
                                $output->writeln("<error>🗴 failed to get binary version, check the push server output for more information</error>");
                                return self::ERROR_OTHER;
                        }
                        usleep(10 * 1000);
                        $binaryVersion = $this->queue->getConnection()->get("notify_push_version");
                } catch (\Exception $e) {
                        $msg = $e->getMessage();
                        $output->writeln("<error>🗴 failed to get binary version: $msg</error>");
                        return self::ERROR_OTHER;
                }
                $appVersion = $this->appManager->getAppVersion('notify_push');
                $appVersionNoMinor = substr($appVersion, 0, strrpos($appVersion, '.'));
                $binaryVersionNoMinor = substr($binaryVersion, 0, strrpos($binaryVersion, '.'));

                if ($appVersionNoMinor === $binaryVersionNoMinor) {
                        $output->writeln("<info>✓ push server is running the same version as the app</info>");
                } else {
                        $output->writeln("<error>🗴 push server (version $binaryVersion) is not the same version as the app (version $appVersion).</error>");
                        return self::ERROR_OTHER;
                }

@francoisPE
Copy link

francoisPE commented Sep 5, 2022

Investigating a bit, I see that notify_push is not going through function getAppinfo in lib/private/App/AppManager.php

@solracsf solracsf closed this as completed Oct 3, 2022
@solracsf solracsf reopened this Oct 9, 2022
@francoisPE
Copy link

francoisPE commented Oct 14, 2022

I an still investigationg that
I run a test_client https://mync.tld user pass
it gives

[2022-10-14 22:20:52.788557 +02:00] INFO [test_client] test_client/src/main.rs:29: Found push server at wss://mync.tld/push/ws
Error:
  × Can't connect to server
  ├─▶ WebSocket protocol error: Missing, duplicated or incorrect header sec-websocket-key
  ╰─▶ Missing, duplicated or incorrect header sec-websocket-key

when I run
php occ notify_push:self-test
it gives

✓ redis is configured
✓ push server is receiving redis messages
✓ push server can load mount info from database
✓ push server can connect to the Nextcloud server
✓ push server is a trusted proxy
An unhandled exception has been thrown:
TypeError: strrpos(): Argument #1 ($haystack) must be of type string, bool given in /mypath/web/apps/notify_push/lib/SelfTest.php:196
Stack trace:
#0 /var/www/clients/client0/web4/web/apps/notify_push/lib/SelfTest.php(196): strrpos()
#1 /var/www/clients/client0/web4/web/apps/notify_push/lib/Command/SelfTest.php(61): OCA\NotifyPush\SelfTest->test()
#2 /var/www/clients/client0/web4/web/3rdparty/symfony/console/Command/Command.php(255): OCA\NotifyPush\Command\SelfTest->execute()
#3 /var/www/clients/client0/web4/web/3rdparty/symfony/console/Application.php(1009): Symfony\Component\Console\Command\Command->run()
#4 /var/www/clients/client0/web4/web/3rdparty/symfony/console/Application.php(273): Symfony\Component\Console\Application->doRunCommand()
#5 /var/www/clients/client0/web4/web/3rdparty/symfony/console/Application.php(149): Symfony\Component\Console\Application->doRun()
#6 /var/www/clients/client0/web4/web/lib/private/Console/Application.php(211): Symfony\Component\Console\Application->run()
#7 /var/www/clients/client0/web4/web/console.php(100): OC\Console\Application->run()
#8 /var/www/clients/client0/web4/web/occ(11): require_once('...')

I am now more or less convinced that's an issue of proxy.
How can I specifically test that ?

I run appache2
I set

ProxyPass /push/ws ws://127.0.0.1:50004/ws
ProxyPass /push/ http://127.0.0.1:50004/
ProxyPassReverse /push/ http://127.0.0.1:50004/

Obviously notify_push server is on port 50004. The first test with test_cleint shows that's not the issue because a server is found.
I confirm with telnet 127.0.0.1 50004
I have 127.0.0.1 in trusted_proxy table...

I check apache log related to that virtualhost and find

[Fri Oct 14 21:53:04.773790 2022] [proxy:error] [pid 3240304:tid 139890524133120] (9)Bad file descriptor: [client hiddenIP] AH03307: ap_proxy_transfer_between_connections: error on sock - ap_pass_brigade

@francoisPE
Copy link

Same as #191

@joshtrichards
Copy link
Member

#191 (comment)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants