irazasyed / telegram-bot-sdk

πŸ€– Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.

Home Page:https://telegram-bot-sdk.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to properly setup to work from behind a corporate proxy?

bvicini opened this issue Β· comments

PHP version

8.1 - 8.2

irazasyed/telegram-bot-sdk version

versions : * v3.11.0

Laravel version (if any)

versions : * v10.9.0

Code To Reproduce the bug

A call to Telegram::getUpdates() timeout because I can't go through our corporate proxy. Everything works well if executed from outside the LAN behind the proxy server. I added HTTPS_PROXY entry in .env file and cleared the config, with no results.

Error stacktrace (if any)

cURL error 28: SSL connection timeout (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for https://api.telegram.org/botxxxxxxxxxx:xxxxxxxxxxxxxxxxxxxx/getUpdates

at vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:210
206β–• }
207β–•
208β–• // Create a connection exception if it was a specific error code.
209β–• $error = isset($connectionErrors[$easy->errno])
➜ 210β–• ? new ConnectException($message, $easy->request, null, $ctx)
211β–• : new RequestException($message, $easy->request, $easy->response, null, $ctx);
212β–•
213β–• return P\Create::rejectionFor($error);
214β–• }

Sorry, labeled as bug by mistake.

Are you sure the proxy you've set using HTTPS_PROXY is valid and you're able to establish a connection?

Alternate way is to host your own version of the Telegram Bot API instance somewhere where you can access by setting the base_bot_url. Docs can be found here

Yes, I am sure, I use it as system wide proxy, for any internet connection. Thank you for pointing me to docs, I give it a try. I tested that I can call external API's through the proxy using Http facade in laravel, maybe the problem is with curl or something else. See you and.. very good work!

After a long time non working on this, the problem is now solved: just a typo in the .env file specification of the proxy address :(. Ty very much!