go-tdlib icon indicating copy to clipboard operation
go-tdlib copied to clipboard

AddProxy errors with "timeout"

Open yamnikov-oleg opened this issue 4 years ago • 5 comments

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.

yamnikov-oleg avatar Mar 20 '20 15:03 yamnikov-oleg

Yet apparently the method still has effect, because if I ignore the error, requests that couldn't work before without proxy start working.

yamnikov-oleg avatar Mar 20 '20 16:03 yamnikov-oleg

Can reproduce this :(

kolayne avatar Jun 28 '20 12:06 kolayne

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

kolayne avatar Jun 28 '20 17:06 kolayne

Same error

0x7b-dev avatar Jul 08 '20 07:07 0x7b-dev

I read tdlib c++ project code, follow the steps must be below: step 1. setTdlibParameters step 2. checkDatabaseEncryptionKey step 3. addProxy

zhangpanyi avatar Aug 27 '20 00:08 zhangpanyi