irazasyed / telegram-bot-sdk

🤖 Telegram Bot API PHP SDK. Lets you build Telegram Bots easily! Supports Laravel out of the box.
https://telegram-bot-sdk.com
BSD 3-Clause "New" or "Revised" License
3.02k stars 669 forks source link

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

Closed bvicini closed 1 year ago

bvicini commented 1 year ago

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▕ }

bvicini commented 1 year ago

Sorry, labeled as bug by mistake.

irazasyed commented 1 year ago

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

bvicini commented 1 year ago

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!

bvicini commented 1 year ago

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!