go-tdlib
go-tdlib copied to clipboard
AddProxy errors with "timeout"
Client.AddProxy
fails with timeout error when I'm trying to add tor as proxy. That same proxy configuration works in my Telegram client, but fails when I try to use it in code.
Am I missing something?
Minimal code reproducing the error:
package main
import (
"fmt"
"log"
"os"
"github.com/Arman92/go-tdlib"
)
func main() {
apiID := os.Getenv("TELEGRAM_API_ID")
apiHash := os.Getenv("TELEGRAM_API_HASH")
botToken := os.Getenv("TELEGRAM_BOT_TOKEN")
client := tdlib.NewClient(tdlib.Config{
APIID: apiID,
APIHash: apiHash,
SystemLanguageCode: "en",
DeviceModel: "Server",
SystemVersion: "1.0.0",
ApplicationVersion: "1.0.0",
UseMessageDatabase: true,
UseFileDatabase: true,
UseChatInfoDatabase: true,
UseTestDataCenter: false,
DatabaseDirectory: "./tdlib-db",
FileDirectory: "./tdlib-files",
IgnoreFileNames: false,
})
_, err := client.AddProxy("localhost", 9050, true, tdlib.NewProxyTypeSocks5("", ""))
if err != nil {
log.Fatalf("AddProxy: %v", err)
}
}
Full log:
[1;36m[ 3][t 3][1584717900.858159304][Td.cpp:4707][#1][!Td][&td_requests] Sending update: updateOption {
name = "version"
value = optionValueString {
value = "1.6.0"
}
}[0m
[1;36m[ 3][t 0][1584717900.858172655][Client.cpp:270][&td_requests] Begin to wait for updates with timeout 10.000000[0m
[1;36m[ 3][t 3][1584717900.858307838][Td.cpp:4707][#1][!Td][&td_requests] Sending update: updateAuthorizationState {
authorization_state = authorizationStateWaitTdlibParameters {
}
}[0m
[1;36m[ 3][t 0][1584717900.858319521][Client.cpp:276][&td_requests] End to wait for updates, returning object 0 0x7f05b8001890[0m
[1;36m[ 3][t 3][1584717900.858332396][Td.cpp:3592][#1][!Td][&td_requests] Receive request 1: addProxy {
server = "localhost"
port = 9050
enable = true
type = proxyTypeSocks5 {
username = ""
password = ""
}
}[0m
[1;36m[ 3][t 0][1584717900.858400583][Client.cpp:270][&td_requests] Begin to wait for updates with timeout 10.000000[0m
[1;36m[ 3][t 0][1584717900.858410835][Client.cpp:276][&td_requests] End to wait for updates, returning object 0 0x7f05b8001e30[0m
[1;36m[ 3][t 0][1584717900.858433008][Client.cpp:270][&td_requests] Begin to wait for updates with timeout 10.000000[0m
2020/03/20 20:25:10 AddProxy: timeout
exit status 1
Thank you.
Yet apparently the method still has effect, because if I ignore the error, requests that couldn't work before without proxy start working.
Can reproduce this :(
Oops, sorry, I was wrong. I can reproduce the issue (i. e. have the same error), but after this, I also get timeout error after almost any request to Telegram
Same error
I read tdlib c++ project code, follow the steps must be below: step 1. setTdlibParameters step 2. checkDatabaseEncryptionKey step 3. addProxy