listen tcp [address]:[port]: bind: cannot assign requested address (golang)
Решил поднять Telegram Bot на Webhooks на Google Cloud Platform. Сгенерировал все нужные сертификаты, использовал внешний статический IP указанный в VM, перепробовал все доступные порты для вебхуков (80, 88, 443, 8443), однако выдает такую ошибку:
listen tcp [address]:[port]: bind: cannot assign requested address
func (bot *Bot) StartBot() error {
// setting webhooks
webHookInfo := tgbotapi.NewWebhookWithCert(fmt.Sprintf("https://%s:%s/%s",
bot.Config.BotAdress,
bot.Config.BotPort, bot.Config.BotToken), bot.Config.CertPath)
_, err := bot.API.SetWebhook(webHookInfo)
if err != nil {
return fmt.Errorf("Error in bot.API.SetWebhook(webHookInfo) : %s", err)
}
//creating handler
message := func(w http.ResponseWriter, r *http.Request) {
text, _ := ioutil.ReadAll(r.Body)
fmt.Println(text)
}
http.HandleFunc("/", message)
return http.ListenAndServeTLS(fmt.Sprintf("%s:%s",
bot.Config.BotAdress,
bot.Config.BotPort),
bot.Config.CertPath,
bot.Config.CertKeyPath, nil)
}
botconfig.json
{
"bot_token": "my_token",
"bot_port": "443",
"bot_adress": "my_ip",
"telegram_url": "https://api.telegram.org/bot",
"cert_path": "my_cert_path",
"cert_key_path": "my_cert_key_path"
}