php-telegram-cli-client
php-telegram-cli-client copied to clipboard
500 internal error in browser?
I installed this package and did all of the specified steps. But the running Example.php displays 500 internal error.
Whats happened? Whats wrong? How could i fix this?
Any help? I'm compiled Telegram-CLI and loged in to my account, and its works like a charm. I installed LAMP ([in Linux], Apache, MySQL, PHP) and i tested them works. Then i installed This project on php project root dir using "Composer". and tested the examples but i couldn't make them run...
All steps of building Telegram-cli, loging in for first time and run it as deamon has beed completed.
Example.php file has been moved to web server root directory. But also unning it cause a 500 Internal server error.
I commented the php codes all and activated them one by one and i found out the problem is this line: $telegram = new \Zyberspace\Telegram\Cli\Client('unix:///tmp/tg.sck');
notices: The file has been checked and is already there. And the telegram-cli is running as a daemon on root user. I added a telegramd group and telegramd user assigned to that group. I detacted that php commands running under apache user account, So i changed the apache user group to telegramd.
Edit:
I changed the httpd.conf
user and group parameters to run at the same (telegramd) account
User telegramd
Group telegramd
And i have restarted the apache and checked the username by
exec('whoami');
The Apache is running under "telegramd" user account.
But nothing again.. What should i do?
Any help?
This is my first time in Linux. Don't disappoint me
error_log file:
[Wed Feb 10 11:02:04.251133 2016] [:error] [pid 1172] [client 10.0.1.24:49168] PHP Warning: stream_socket_client(): unable to connect to unix:///tmp/tg.sck (No such file or directory) in /var/www/html/vendor/zyberspace/telegram-cli-client/lib/Zyberspace/Telegram/Cli/RawClient.php on line 48 [Wed Feb 10 11:02:04.251332 2016] [:error] [pid 1172] [client 10.0.1.24:49168] PHP Fatal error: Uncaught exception 'Zyberspace\Telegram\Cli\ClientException' with message 'Could not connect to socket "unix:///tmp/tg.sck"' in /var/www/html/vendor/zyberspace/telegram-cli-client/lib/Zyberspace/Telegram/Cli/RawClient.php:51\nStack trace:\n#0 /var/www/html/example.php(10): Zyberspace\Telegram\Cli\RawClient->__construct('unix:///tmp/tg....')\n#1 {main}\n thrown in /var/www/html/vendor/zyberspace/telegram-cli-client/lib/Zyberspace/Telegram/Cli/RawClient.php on line 51
Hi, i am currently on vacation so excuse me if i am not able to answer in under 24 hours. :)
The error in your log says that the client is unable to connect to the socket (/tmp/tg.sck
).
This either means the socket does not exists or the file permissions are wrong.
Did you do this part in the README?
chown :telegram /tmp/tg.sck chmod g+rwx /tmp/tg.sck
Note that you said that you are using "telegramd" as user, so your chown
command would be
chown :telegramd /tmp/tg.sck
To check the file permissions you can just run this:
ls -l /tmp/tg.sck
If you are running the telegram cli as root user and you did not change the socket permissions afterwards the /tmp/tg.sck
will be owned by root. Probably with the file permissions 770.
But under linux the socket (.sck
) needs to be writeable by the user trying to access it.
So if the file is owned by user root
and group root
you need to change the file permission to 777.
chmod a+rwx /tmp/tg.sck
But you should really prefer the method above with the groups, as it is more secure. A can find a good tutorial for unix/linux file permission here.
I did all the advises in past but it doesn't work. I guess the problem is in my PHP or Apache web server applications.
I passed this problem (temporarily) by running the Telegram-CLI on a VM Machine and using the PHP-Telegram-CLI-Client on my host machine (windows) via listening on port in TG-CLI ( -S [port#] )
At all, Thanks for this good job
i got this error in firefox when i opened example: Warning: stream_socket_client(): unable to connect to unix:///tmp/tg.sck (Permission denied) in /var/www/html/vendor/zyberspace/telegram-cli-client/lib/Zyberspace/Telegram/Cli/RawClient.php on line 48
Fatal error: Uncaught exception 'Zyberspace\Telegram\Cli\ClientException' with message 'Could not connect to socket "unix:///tmp/tg.sck"' in /var/www/html/vendor/zyberspace/telegram-cli-client/lib/Zyberspace/Telegram/Cli/RawClient.php on line 50
but when i run via php example.php the problem solved! so problem is on the permission.