Вчера все работало, как и ожидалось, в моем приложении Go.Я ничего не менял, связанный с брандмауэрами / конфигурациями.Сегодня, когда я пытаюсь отправить запрос на "https://fcm.googleapis.com/fcm/send", я получил следующие ошибки:
Post https://fcm.googleapis.com/fcm/send: Наберите tcp: lookup fcm.googleapis.com наIP: 53: чтение udp IP: 37987-> IP: 53: тайм-аут ввода / вывода
Я не знаю, как происходит эта ошибка. Конфигурация брандмауэра остается прежней. Странно, что если ятестируйте локально, тогда все работает нормально, но при загрузке на сервер я получаю эту ошибку.
Конфигурация NGINX в Plesk:
server_name mydomain.com;
location /api/v1 {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
fastcgi_read_timeout 2500;
proxy_connect_timeout 2500;
proxy_send_timeout 2500;
proxy_read_timeout 2500;
send_timeout 2500;
proxy_pass http://localhost:8082/api/v1;
}
ОБНОВЛЕНИЕ Проверка журналов, полученных от NGINX
499 POST /api/v1/notifications HTTP/1.1
Мой домен не имеет сертификата SSL, может ли это быть причиной истечения времени ожидания?
Код ОБНОВЛЕНИЯ:
client, err := fcm.NewClient("KEY")
if err != nil {
fmt.Println(err)
}
handler.FirebaseClient = client
firebaseNotification := &fcm.Message{
Notification: &fcm.Notification{
Title: notificationData.Title,
Body: notificationData.Body,
},
}
firebaseNotification.RegistrationIDs = notificationData.Tokens
fmt.Println(firebaseNotification)
_, err := FirebaseClient.Send(firebaseNotification)
if err != nil {
fmt.Println(err)
return
}
Функция отправки из библиотеки github.com/appleboy/ go-fcm
func (c *Client) send(data []byte) (*Response, error) {
// create request
req, err := http.NewRequest("POST", c.endpoint, bytes.NewBuffer(data))
if err != nil {
return nil, err
}
// add headers
req.Header.Add("Authorization", fmt.Sprintf("key=%s", c.apiKey))
req.Header.Add("Content-Type", "application/json")
// execute request
resp, err := c.client.Do(req)
if err != nil {
return nil, connectionError(err.Error())
}
defer resp.Body.Close()
// check response status
if resp.StatusCode != http.StatusOK {
if resp.StatusCode >= http.StatusInternalServerError {
return nil, serverError(fmt.Sprintf("%d error: %s", resp.StatusCode, resp.Status))
}
return nil, fmt.Errorf("%d error: %s", resp.StatusCode, resp.Status)
}
// build return
response := new(Response)
if err := json.NewDecoder(resp.Body).Decode(response); err != nil {
return nil, err
}
return response, nil
}