phpjsonxcachesuhosin

json_encode - PHP gives uncomplete json string


First my Setting: PHP 5.3.2 - with Suoshin and xCache lighttpd/1.4.26

My Code is too much to Post it here. I will discribe it.

File x.php is loading some PHP - Classe, init them, executes some functions -> getting an Result array.

If I print_r this array I get a full result.

But I've I use json_encode, it cuts it every time on the same position. -> json gets invalid.
Example: print_r-

Array
(
    [test1] => Array
        (
            [test2] => 2
            [test3] => Array
                (
                    [test4] => 4
                )

        )

)

json -

{"test1":{"test2":2,"test3":{"te

Error Log says the following:

(mod_fastcgi.c.2582) unexpected end-of-file (perhaps the fastcgi process died): pid: 16708 socket: unix:/tmp/php5.socket-1
(mod_fastcgi.c.3382) response already sent out, but backend returned error on socket: unix:/tmp/php5.socket-1 for /x.php?, terminating connection

The Question is how can i track whats the Error? Or anybody knows whats the Problem?


Solution

  • Sounds like a buffering problem. Make sure that your response buffer is flushed before the connection is closed.