Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PT][BUG] Uso de proxy em rede sem acesso à Internet #535

Open
zimbres opened this issue Apr 16, 2024 · 3 comments
Open

[PT][BUG] Uso de proxy em rede sem acesso à Internet #535

zimbres opened this issue Apr 16, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@zimbres
Copy link

zimbres commented Apr 16, 2024

Ao tentar inicializar a Evolution em uma rede com acesso restrito à Internet onde todo o acesso deve ser feito através de um proxy Squid, alguns comportamentos são observados:

  • Sem configurações de proxy no container, o mesmo aumenta o uso de memoria e cpu rapidamente devido à checagem de versão que a baileys faz para "https://raw.githubusercontent.com/WhiskeySockets/Baileys/master/src/Defaults/baileys-version.json" até a exaustão de recursos da maquina;
  • Se configurado o container com variáveis de ambiente "https_proxy", a checagem de versão da baileys não termina com sucesso com o erro 502 no Squid;
  • Se liberado no Firewall para que a baileys consiga passar do ponto da checagem de versão, ao tentar setar o proxy na instância é retornado um erro 400 "Invalid Proxy". Os parâmetros utilizados foram:
{
  "enabled": true,
  "proxy": {
    "host": "192.168.100.130",
    "port": "3128",
    "protocol": "http"
  }
}

Ambiente:

  • atendai/evolution-api
  • v1.7.2
@zimbres zimbres added the bug Something isn't working label Apr 16, 2024
@zimbres
Copy link
Author

zimbres commented Apr 17, 2024

Aparentemente o axios não gosta de requisição https sobre um proxy http o que requereria uma implementação diferente na função fetchLatestBaileysVersion.

Pelo que consegui aferir, na EV a função da baileys é apenas informativa, seria o caso de executar essa parte do código apenas se uma variável de ambiente estivesse configurada para true, exemplo: "CHECK_BAILEYS_VERSION"?

@zimbres
Copy link
Author

zimbres commented Apr 17, 2024

Pelo que entendi, a linha "return response?.data !== serverIp?.data;" do Proxy.Controller vai devolver falso no caso de uso em questão onde o IP do Proxy é o mesmo do acesso direto uma vez que é um proxy interno.

Para ambientes corporativos onde o acesso à Internet deve se dar sempre pelo proxy, essa "testProxy" não vai funcionar.

@zimbres
Copy link
Author

zimbres commented Apr 18, 2024

Em todo o caso, a baileys não consegue trabalhar com um proxy Squid, https over http proxy. Parace faltar uma implementação de, por exemplo, 'https-proxy-agent'

{
	"level": 50,
	"time": 1713452754681,
	"pid": 4633,
	"hostname": "evolution",
	"err": {
		"message": "Request failed with status code 502",
		"name": "AxiosError",
		"stack": "AxiosError: Request failed with status code 502\n    at settle (file:///root/evolution-api/node_modules/axios/lib/core/settle.js:19:12)\n    at RedirectableRequest.handleResponse (file:///root/evolution-api/node_modules/axios/lib/adapters/http.js:537:9)\n    at RedirectableRequest.emit (node:events:517:28)\n    at RedirectableRequest.emit (node:domain:489:12)\n    at RedirectableRequest._processResponse (/root/evolution-api/node_modules/follow-redirects/index.js:398:10)\n    at RedirectableRequest._onNativeResponse (/root/evolution-api/node_modules/follow-redirects/index.js:91:12)\n    at Object.onceWrapper (node:events:632:26)\n    at ClientRequest.emit (node:events:517:28)\n    at ClientRequest.emit (node:domain:489:12)\n    at HTTPParser.parserOnIncomingClient (node:_http_client:700:27)\n    at Axios.request (file:///root/evolution-api/node_modules/axios/lib/core/Axios.js:45:41)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async getHttpStream (/root/evolution-api/node_modules/@whiskeysockets/baileys/lib/Utils/messages-media.js:317:21)\n    at async downloadEncryptedContent (/root/evolution-api/node_modules/@whiskeysockets/baileys/lib/Utils/messages-media.js:450:21)\n    at async downloadHistory (/root/evolution-api/node_modules/@whiskeysockets/baileys/lib/Utils/history.js:14:20)\n    at async downloadAndProcessHistorySyncNotification (/root/evolution-api/node_modules/@whiskeysockets/baileys/lib/Utils/history.js:81:24)\n    at async processMessage (/root/evolution-api/node_modules/@whiskeysockets/baileys/lib/Utils/process-message.js:146:34)\n    at async Promise.all (index 1)\n    at async /root/evolution-api/node_modules/@whiskeysockets/baileys/lib/Socket/chats.js:739:9\n    at async /root/evolution-api/node_modules/@whiskeysockets/baileys/lib/Utils/event-buffer.js:105:36",
		"config": {
			"transitional": {
				"silentJSONParsing": true,
				"forcedJSONParsing": true,
				"clarifyTimeoutError": false
			},
			"adapter": [
				"xhr",
				"http"
			],
			"transformRequest": [
				null
			],
			"transformResponse": [
				null
			],
			"timeout": 0,
			"xsrfCookieName": "XSRF-TOKEN",
			"xsrfHeaderName": "X-XSRF-TOKEN",
			"maxContentLength": null,
			"maxBodyLength": null,
			"env": {},
			"headers": {
				"Accept": "application/json, text/plain, */*",
				"Origin": "https://web.whatsapp.com",
				"User-Agent": "axios/1.6.8",
				"Accept-Encoding": "gzip, compress, deflate, br"
			},
			"responseType": "stream",
			"method": "get",
			"url": "https://mmg.whatsapp.net/v/t62.31111-24/25392554_75620322698702_72013799226106170_n.enc?ccb=11-4&oh=01_Q5AaINbpuxF-DwX61I3qi8Jw8N79Jb1dOCLkhbHxHI_gGjZ&oe=6648B3AD&_nc_sid=5e03e0"
		},
		"code": "ERR_BAD_RESPONSE",
		"status": 502
	},
	"msg": "unexpected error in 'processing message'"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants
@zimbres and others