没有不值得去解决的问题,也没有不值得去学习的技术!

Investigating the Exception: Trying to Access Array Offset on Value of Type Null in /vendor/hprose/hprose/src/Hprose/Client.php:383

Because this API requests the RPC server based on Hprose, I checked the corresponding runtime logs. Exception: Trying to access array offset on value of type null in /mcloud/www/channel-pub-api/vendor/hprose/hprose/src/Hprose/Client.php:383.

1. API response: Trying to access array offset on value of type null. See Figure 1.

API response: Trying to access array offset on value of type null.
Figure 1

2. Because this API requests the RPC server based on Hprose, I checked the corresponding runtime logs. Exception: Trying to access array offset on value of type null in /mcloud/www/channel-pub-api/vendor/hprose/hprose/src/Hprose/Client.php:383. See Figure 2.

Because this API requests the RPC server based on Hprose, I checked the corresponding runtime logs. Exception: Trying to access array offset on value of type null in /mcloud/www/channel-pub-api/vendor/hprose/hprose/src/Hprose/Client.php:383.
Figure 2
Plaintext

2021-01-19 19:01:06 [10.42.22.195][-][-][error][Exception] Exception: Trying to access array offset on value of type null in /mcloud/www/channel-pub-api/vendor/hprose/hprose/src/Hprose/Client.php:383
Stack trace:
#0 /mcloud/www/channel-pub-api/vendor/hprose/hprose/src/Hprose/Client.php(477): Hprose\Client->decode('Es51"Trying to ...', Array, Object(stdClass))
#1 /mcloud/www/channel-pub-api/vendor/hprose/hprose/src/Hprose/Client.php(489): Hprose\Client->syncInvokeHandler('unBindAccount', Array, Object(stdClass))
#2 /mcloud/www/channel-pub-api/vendor/hprose/hprose/src/Hprose/Client.php(103): Hprose\Client->invokeHandler('unBindAccount', Array, Object(stdClass))
#3 /mcloud/www/channel-pub-api/vendor/hprose/hprose/src/Hprose/Client.php(608): Hprose\Client->Hprose\{closure}('unBindAccount', Array, Object(stdClass))
#4 /mcloud/www/channel-pub-api/vendor/hprose/hprose/src/Hprose/Client.php(438): Hprose\Client->invoke('unBindAccount', Array)
#5 /mcloud/www/channel-pub-api/common/logics/rpc/vtt/VttAppUser.php(77): Hprose\Client->__call('unBindAccount', Array)
#6 /mcloud/www/channel-pub-api/vtt/rests/vtt_app_user/DeleteAction.php(64): common\logics\rpc\vtt\VttAppUser->delete(Array)
#7 [internal function]: vtt\rests\vtt_app_user\DeleteAction->run('46da43905a1911e...')
#8 /mcloud/www/channel-pub-api/vendor/yiisoft/yii2/base/Action.php(94): call_user_func_array(Array, Array)
#9 /mcloud/www/channel-pub-api/vendor/yiisoft/yii2/base/Controller.php(157): yii\base\Action->runWithParams(Array)
#10 /mcloud/www/channel-pub-api/vendor/yiisoft/yii2/base/Module.php(528): yii\base\Controller->runAction('delete', Array)
#11 /mcloud/www/channel-pub-api/vendor/yiisoft/yii2/web/Application.php(103): yii\base\Module->runAction('v1/vtt-app-user...', Array)
#12 /mcloud/www/channel-pub-api/vendor/yiisoft/yii2/base/Application.php(386): yii\web\Application->handleRequest(Object(yii\web\Request))
#13 /mcloud/www/channel-pub-api/vtt/web/index.php(17): yii\base\Application->run()
#14 {main}

3. I decided to troubleshoot the issue by printing log files. Edit /mcloud/www/channel-pub-api/vendor/hprose/hprose/src/Hprose/Client.php

PHP

    private function syncInvokeHandler($name, array &$args, stdClass $context) {
        $request = $this->encode($name, $args, $context);
        $beforeFilterHandler = $this->beforeFilterHandler;
        $response = $beforeFilterHandler($request, $context);
        file_put_contents(Yii::getAlias('@runtime') . '/vendor-hprose-hprose-src-Hprose-Client-response-' . microtime(true) . '-' . mt_rand()  . '.txt', print_r($response, true), FILE_APPEND | LOCK_EX);
        file_put_contents(Yii::getAlias('@runtime') . '/vendor-hprose-hprose-src-Hprose-Client-args-' . microtime(true) . '-' . mt_rand()  . '.txt', print_r($args, true), FILE_APPEND | LOCK_EX);
        file_put_contents(Yii::getAlias('@runtime') . '/vendor-hprose-hprose-src-Hprose-Client-context-' . microtime(true) . '-' . mt_rand()  . '.txt', print_r($context, true), FILE_APPEND | LOCK_EX);
        return $this->decode($response, $args, $context);
    }

4. When the RPC server responds successfully, view the file: vendor-hprose-hprose-src-Hprose-Client-response-1611058217.4824-543667088.txt

Plaintext
Rm3{s4"code"i99999;s7"message"s9"三方平台绑定失败!"s4"data"a{}}z

5. When the RPC server responds successfully, view the file: vendor-hprose-hprose-src-Hprose-Client-args-1611058217.4831-887085467.txt

Plaintext

Array
(
    [0] => Array
        (
            [password] => b4260bf3006f7563708c1ca4e1c4cb62%2C8c16f7071ded6692c10721d2ac2c2cbf
            [channel_type_code] => vtt_toutiao_pro
            [permission] => 2
            [source_uuid] => 468e5e929edf30f4097ca89168decde9
            [source] => scms
            [account] => 61ffb6b5a2d64dcba10352d765c72908
            [channelCode] => toutiao
            [status] => 1
            [group_id] => 015ce30b116ce86058fa6ab4fea4ac63
            [platform_code] => vtt_toutiao_pro
            [source_system] => scms
            [source_group_id] => 015ce30b116ce86058fa6ab4fea4ac63
            [source_user_token] => 468e5e929edf30f4097ca89168decde9
            [origin_account_uuid] => 4ab9a31c5a4f11eb965d54ee75d2ebc1
        )

)


6. When the RPC server responds successfully, view the file: vendor-hprose-hprose-src-Hprose-Client-context-1611058217.4836-1374300614.txt

Plaintext

stdClass Object
(
    [client] => Hprose\Http\Client Object
        (
            [host:Hprose\Http\Client:private] => rpc.channel-pub-vtt.localhost
            [path:Hprose\Http\Client:private] => /hprose/index
            [secure:Hprose\Http\Client:private] => 
            [proxy] => 
            [keepAlive] => 1
            [keepAliveTimeout] => 300
            [header:Hprose\Http\Client:private] => Array
                (
                    [Content-type] => application/hprose
                )

            [options:Hprose\Http\Client:private] => Array
                (
                    [64] => 
                    [113] => 1
                    [42] => 1
                    [19913] => 1
                    [47] => 1
                    [99] => 1
                )

            [curl:Hprose\Http\Client:private] => 
            [curlVersionLittleThan720:Hprose\Http\Client:private] => 
            [results:Hprose\Http\Client:private] => Array
                (
                )

            [curls:Hprose\Http\Client:private] => Array
                (
                )

            [contexts:Hprose\Http\Client:private] => Array
                (
                )

            [index:Hprose\Client:private] => 0
            [uriList:Hprose\Client:private] => Array
                (
                    [0] => http://rpc.channel-pub-vtt.localhost/hprose/index
                )

            [async:protected] => 
            [uri] => http://rpc.channel-pub-vtt.localhost/hprose/index
            [filters] => Array
                (
                )

            [timeout] => 30000
            [retry] => 10
            [idempotent] => 
            [failswitch] => 
            [failround] => 0
            [byref] => 
            [simple] => 
            [onError] => 
            [onFailswitch] => 
            [methodCache:Hprose\Client:private] => Array
                (
                )

            [topics:Hprose\Client:private] => 
            [id:Hprose\Client:private] => 
            [invokeHandlers:Hprose\HandlerManager:private] => Array
                (
                )

            [beforeFilterHandlers:Hprose\HandlerManager:private] => Array
                (
                )

            [afterFilterHandlers:Hprose\HandlerManager:private] => Array
                (
                )

            [defaultInvokeHandler:protected] => Closure Object
                (
                    [static] => Array
                        (
                            [self] => Hprose\Http\Client Object
 *RECURSION*
                        )

                    [this] => Hprose\Http\Client Object
 *RECURSION*
                    [parameter] => Array
                        (
                            [$name] => 
                            [&$args] => 
                            [$context] => 
                        )

                )

            [defaultBeforeFilterHandler:protected] => Closure Object
                (
                    [static] => Array
                        (
                            [self] => Hprose\Http\Client Object
 *RECURSION*
                        )

                    [this] => Hprose\Http\Client Object
 *RECURSION*
                    [parameter] => Array
                        (
                            [$request] => 
                            [$context] => 
                        )

                )

            [defaultAfterFilterHandler:protected] => Closure Object
                (
                    [static] => Array
                        (
                            [self] => Hprose\Http\Client Object
 *RECURSION*
                        )

                    [this] => Hprose\Http\Client Object
 *RECURSION*
                    [parameter] => Array
                        (
                            [$request] => 
                            [$context] => 
                        )

                )

            [invokeHandler:protected] => Closure Object
                (
                    [static] => Array
                        (
                            [self] => Hprose\Http\Client Object
 *RECURSION*
                        )

                    [this] => Hprose\Http\Client Object
 *RECURSION*
                    [parameter] => Array
                        (
                            [$name] => 
                            [&$args] => 
                            [$context] => 
                        )

                )

            [beforeFilterHandler:protected] => Closure Object
                (
                    [static] => Array
                        (
                            [self] => Hprose\Http\Client Object
 *RECURSION*
                        )

                    [this] => Hprose\Http\Client Object
 *RECURSION*
                    [parameter] => Array
                        (
                            [$request] => 
                            [$context] => 
                        )

                )

            [afterFilterHandler:protected] => Closure Object
                (
                    [static] => Array
                        (
                            [self] => Hprose\Http\Client Object
 *RECURSION*
                        )

                    [this] => Hprose\Http\Client Object
 *RECURSION*
                    [parameter] => Array
                        (
                            [$request] => 
                            [$context] => 
                        )

                )

        )

    [userdata] => stdClass Object
        (
        )

    [mode] => 0
    [oneway] => 
    [byref] => 
    [simple] => 
    [failswitch] => 
    [idempotent] => 
    [retry] => 10
    [retried] => 0
    [timeout] => 30000
    [httpHeader] => Array
        (
            [Server] => nginx/1.10.1
            [Date] => Tue, 19 Jan 2021 12:10:17 GMT
            [Content-Type] => text/plain;charset=UTF-8
            [Content-Length] => 74
            [Connection] => keep-alive
            [X-Debug-Tag] => 6006cc28c62e9
            [X-Debug-Duration] => 689
            [X-Debug-Link] => /debug/default/view?tag=6006cc28c62e9
        )

)


7. When the RPC server throws an exception, view the file: vendor-hprose-hprose-src-Hprose-Client-response-1611058702.7009-1892363890.txt. See Figure 3.

When the RPC server throws an exception, view the file: vendor-hprose-hprose-src-Hprose-Client-response-1611058702.7009-1892363890.txt
Figure 3
Plaintext

Es51"Trying to access array offset on value of type null"z

8. When the RPC server throws an exception, view the file: vendor-hprose-src-Hprose-Client-args-1611058702.7011-780493657.txt.

Plaintext

Array
(
    [0] => Array
        (
            [origin_account_uuid] => 77d007c85a2311eb9df79988cc614e10
        )

)

9. When the RPC server throws an exception, view the file: vendor-hprose-hprose-src-Hprose-Client-context-1611058702.7012-1316008257.txt.

Plaintext

stdClass Object
(
    [client] => Hprose\Http\Client Object
        (
            [host:Hprose\Http\Client:private] => vtt1.channel-pub.wjtest.chinamcloud.cn
            [path:Hprose\Http\Client:private] => /hprose/index
            [secure:Hprose\Http\Client:private] =>
            [proxy] =>
            [keepAlive] => 1
            [keepAliveTimeout] => 300
            [header:Hprose\Http\Client:private] => Array
                (
                    [Content-type] => application/hprose
                )

            [options:Hprose\Http\Client:private] => Array
                (
                    [64] =>
                    [113] => 1
                    [42] => 1
                    [19913] => 1
                    [47] => 1
                    [99] => 1
                )

            [curl:Hprose\Http\Client:private] =>
            [curlVersionLittleThan720:Hprose\Http\Client:private] =>
            [results:Hprose\Http\Client:private] => Array
                (
                )

            [curls:Hprose\Http\Client:private] => Array
                (
                )

            [contexts:Hprose\Http\Client:private] => Array
                (
                )

            [index:Hprose\Client:private] => 0
            [uriList:Hprose\Client:private] => Array
                (
                    [0] => http://vtt1.channel-pub.wjtest.chinamcloud.cn/hprose/index
                )

            [async:protected] =>
            [uri] => http://vtt1.channel-pub.wjtest.chinamcloud.cn/hprose/index
            [filters] => Array
                (
                )

            [timeout] => 30000
            [retry] => 10
            [idempotent] =>
            [failswitch] =>
            [failround] => 0
            [byref] =>
            [simple] =>
            [onError] =>
            [onFailswitch] =>
            [methodCache:Hprose\Client:private] => Array
                (
                )

            [topics:Hprose\Client:private] =>
            [id:Hprose\Client:private] =>
            [invokeHandlers:Hprose\HandlerManager:private] => Array
                (
                )

            [beforeFilterHandlers:Hprose\HandlerManager:private] => Array
                (
                )

            [afterFilterHandlers:Hprose\HandlerManager:private] => Array
                (
                )

            [defaultInvokeHandler:protected] => Closure Object
                (
                    [static] => Array
                        (
                            [self] => Hprose\Http\Client Object
 *RECURSION*
                        )

                    [this] => Hprose\Http\Client Object
 *RECURSION*
                    [parameter] => Array
                        (
                            [$name] => 
                            [&$args] => 
                            [$context] => 
                        )

                )

            [defaultBeforeFilterHandler:protected] => Closure Object
                (
                    [static] => Array
                        (
                            [self] => Hprose\Http\Client Object
 *RECURSION*
                        )

                    [this] => Hprose\Http\Client Object
 *RECURSION*
                    [parameter] => Array
                        (
                            [$request] => 
                            [$context] => 
                        )

                )

            [defaultAfterFilterHandler:protected] => Closure Object
                (
                    [static] => Array
                        (
                            [self] => Hprose\Http\Client Object
 *RECURSION*
                        )

                    [this] => Hprose\Http\Client Object
 *RECURSION*
                    [parameter] => Array
                        (
                            [$request] => 
                            [$context] => 
                        )

                )

            [invokeHandler:protected] => Closure Object
                (
                    [static] => Array
                        (
                            [self] => Hprose\Http\Client Object
 *RECURSION*
                        )

                    [this] => Hprose\Http\Client Object
 *RECURSION*
                    [parameter] => Array
                        (
                            [$name] => 
                            [&$args] => 
                            [$context] => 
                        )

                )

            [beforeFilterHandler:protected] => Closure Object
                (
                    [static] => Array
                        (
                            [self] => Hprose\Http\Client Object
 *RECURSION*
                        )

                    [this] => Hprose\Http\Client Object
 *RECURSION*
                    [parameter] => Array
                        (
                            [$request] => 
                            [$context] => 
                        )

                )

            [afterFilterHandler:protected] => Closure Object
                (
                    [static] => Array
                        (
                            [self] => Hprose\Http\Client Object
 *RECURSION*
                        )

                    [this] => Hprose\Http\Client Object
 *RECURSION*
                    [parameter] => Array
                        (
                            [$request] => 
                            [$context] => 
                        )

                )

        )

    [userdata] => stdClass Object
        (
        )

    [mode] => 0
    [oneway] =>
    [byref] =>
    [simple] =>
    [failswitch] =>
    [idempotent] =>
    [retry] => 10
    [retried] => 0
    [timeout] => 30000
    [httpHeader] => Array
        (
            [Server] => www.chinamcloud.com
            [Date] => Tue, 19 Jan 2021 12:18:22 GMT
            [Content-Type] => text/plain;charset=UTF-8
            [Content-Length] => 58
        )

)

10. Therefore, I conclude that this is an issue with the RPC server, and it needs to be resolved by the server side.

关于作者 · 持续学习与技术实践

我是一名拥有 15 年以上开发经验的技术从业者,自 2013 年起持续运营个人技术博客,记录工作与个人项目中遇到的真实问题,以及解决问题过程中的探索、实践和思考。

除了技术写作,我也在持续开发和维护自己的独立项目,探索新技术和新工具在实际场景中的应用。我始终相信,没有不值得去解决的问题,也没有不值得去学习的技术。

如果这篇文章对你有所帮助,欢迎浏览博客中的其他文章,也欢迎交流技术经验与想法。

关于我  ·  GitHub  ·  邮件联系