
![]() |
Наши проекты:
Журнал · Discuz!ML · Wiki · DRKB · Помощь проекту |
|
ПРАВИЛА | FAQ | Помощь | Поиск | Участники | Календарь | Избранное | RSS |
[216.73.216.75] |
![]() |
|
![]() |
Сообщ.
#1
,
|
|
Получаю ошибку Exception EIdHTTPProtocolException с сообщением HTTP/1.1 400 Bad Request.
Прокси 100% рабочий, логин-пароль верный. Проверено в браузерах FireFox и IE. ЧЯДНТ? ![]() ![]() {$APPTYPE CONSOLE} uses System.SysUtils, IdHTTP, IdSocks, IdSSLOpenSSL, IdCookieManager, IdCompressorZLib, IdURI; const DefaultUserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36'; DefaultReferer = 'https://google.com/'; ProxyURI = 'https://user:pwd@1.2.3.4:10733'; // здесь, естественно, проставлены нужные данные RequestURL = 'https://2ip.ru'; var HTTPS: TIdHTTP; begin HTTPS := TIdHTTP.Create(nil); with HTTPS do begin IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(HTTPS); CookieManager := TIdCookieManager.Create(HTTPS); Compressor := TIdCompressorZLib.Create(HTTPS); HandleRedirects := True; AllowCookies := True; Request.UserAgent := DefaultUserAgent; Request.Accept := '*/*'; Request.AcceptEncoding := 'gzip, deflate, br'; Request.ContentType := 'text/plain;charset=UTF-8'; Request.AcceptLanguage := 'ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7'; Request.Connection := 'keep-alive'; Request.Referer := DefaultReferer; with ProxyParams, TIdURI.Create(ProxyURI) do begin ProxyServer := Host; ProxyPort := StrToIntDef(Port, 8080); ProxyUsername := Username; ProxyPassword := Password; end; WriteLn(Get(RequestURL)); Free; end; end. Добавлено Тот же прокси для SOCKS (там отличается только порт) прекрасно работает: ![]() ![]() {$APPTYPE CONSOLE} uses System.SysUtils, IdHTTP, IdSocks, IdSSLOpenSSL, IdCookieManager, IdCompressorZLib, IdURI; const DefaultUserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36'; DefaultReferer = 'https://google.com/'; ProxyURI = 'socks5://user:pwd@1.2.3.4:3128:10734'; // здесь, естественно, проставлены нужные данные ProxySocksVersion = svSocks5; RequestURL = 'https://2ip.ru'; var HTTPS: TIdHTTP; begin HTTPS := TIdHTTP.Create(nil); with HTTPS do begin IOHandler := TIdSSLIOHandlerSocketOpenSSL.Create(HTTPS); CookieManager := TIdCookieManager.Create(HTTPS); Compressor := TIdCompressorZLib.Create(HTTPS); HandleRedirects := True; AllowCookies := True; Request.UserAgent := DefaultUserAgent; Request.Accept := '*/*'; Request.AcceptEncoding := 'gzip, deflate, br'; Request.ContentType := 'text/plain;charset=UTF-8'; Request.AcceptLanguage := 'ru-RU,ru;q=0.9,en-US;q=0.8,en;q=0.7'; Request.Connection := 'keep-alive'; Request.Referer := DefaultReferer; with TIdSSLIOHandlerSocketOpenSSL(IOHandler), TIdURI.Create(ProxyURI) do begin if not Assigned(TransparentProxy) then TransparentProxy := TIdSocksInfo.Create(HTTPS); begin TransparentProxy.Host := Host; TransparentProxy.Port := StrToIntDef(Port, 1080); TransparentProxy.Username := Username; TransparentProxy.Password := Password; if Username = '' then TIdSocksInfo(TransparentProxy).Authentication := saNoAuthentication else TIdSocksInfo(TransparentProxy).Authentication := saUsernamePassword; TIdSocksInfo(TransparentProxy).Version := ProxySocksVersion; end; end; WriteLn(Get(RequestURL)); Free; end; end. |
![]() |
Сообщ.
#2
,
|
|
В первом коде пишу ProxyURI = 'https://66.94.120.161:443' – всё работает.
А этот прокси работает в браузерах, но в проге не хочет. Не понимаю, в чём прикол?! Добавлено Причём, с прокси он соединяется, но почему-то выдаёт ошибку 400. Если поменять пароль, скажем, на неверный, будет ошибка авторизации. Добавлено Короче, вот что я ещё сделал. Накидал прожку на Python: ![]() ![]() import requests #proxy = { 'https': '66.94.120.161:443' } proxy = { 'https': 'https://***:***@1.2.3.4:10733' } print(requests.get('https://2ip.ru', proxies=proxy).json()) Результат: ![]() ![]() Traceback (most recent call last): File "D:\Lang\Python3\lib\site-packages\urllib3\connectionpool.py", line 700, in urlopen self._prepare_proxy(conn) File "D:\Lang\Python3\lib\site-packages\urllib3\connectionpool.py", line 994, in _prepare_proxy conn.connect() File "D:\Lang\Python3\lib\site-packages\urllib3\connection.py", line 364, in connect self.sock = conn = self._connect_tls_proxy(hostname, conn) File "D:\Lang\Python3\lib\site-packages\urllib3\connection.py", line 499, in _connect_tls_proxy socket = ssl_wrap_socket( File "D:\Lang\Python3\lib\site-packages\urllib3\util\ssl_.py", line 453, in ssl_wrap_socket ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls) File "D:\Lang\Python3\lib\site-packages\urllib3\util\ssl_.py", line 495, in _ssl_wrap_socket_impl return ssl_context.wrap_socket(sock) File "D:\Lang\Python3\lib\ssl.py", line 500, in wrap_socket return self.sslsocket_class._create( File "D:\Lang\Python3\lib\ssl.py", line 1040, in _create self.do_handshake() File "D:\Lang\Python3\lib\ssl.py", line 1309, in do_handshake self._sslobj.do_handshake() ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1129) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "D:\Lang\Python3\lib\site-packages\requests\adapters.py", line 440, in send resp = conn.urlopen( File "D:\Lang\Python3\lib\site-packages\urllib3\connectionpool.py", line 785, in urlopen retries = retries.increment( File "D:\Lang\Python3\lib\site-packages\urllib3\util\retry.py", line 592, in increment raise MaxRetryError(_pool, url, error or ResponseError(cause)) urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='2ip.ru', port=443): Max retries exceeded with url: / (Caused by ProxyError('Your proxy appears to only use HTTP and not HTTPS, try changing your proxy URL to be HTTP. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#https-proxy-error-http-proxy', SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1129)')))) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "D:\proj\download.py", line 5, in <module> print(requests.get('https://2ip.ru', proxies=proxy).json()) File "D:\Lang\Python3\lib\site-packages\requests\api.py", line 75, in get return request('get', url, params=params, **kwargs) File "D:\Lang\Python3\lib\site-packages\requests\api.py", line 61, in request return session.request(method=method, url=url, **kwargs) File "D:\Lang\Python3\lib\site-packages\requests\sessions.py", line 529, in request resp = self.send(prep, **send_kwargs) File "D:\Lang\Python3\lib\site-packages\requests\sessions.py", line 645, in send r = adapter.send(request, **kwargs) File "D:\Lang\Python3\lib\site-packages\requests\adapters.py", line 513, in send raise ProxyError(e, request=request) requests.exceptions.ProxyError: HTTPSConnectionPool(host='2ip.ru', port=443): Max retries exceeded with url: / (Caused by ProxyError('Your proxy appears to only use HTTP and not HTTPS, try changing your proxy URL to be HTTP. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#https-proxy-error-http-proxy', SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1129)')))) Неверная версия SSL ??? |
Сообщ.
#3
,
|
|
|
Сначала убедиться, что трафик от твоей программы до прокси идентичен трафику от браузеров.
|
![]() |
Сообщ.
#4
,
|
|
Fr0sT, каким образом?
![]() Вообще, этот прокси для использования в софте, по идее, не должен какие-то особенные требования предъявлять ![]() |
Сообщ.
#5
,
|
|
|
Цитата Jin X @ каким образом? ![]() Сниффер. Или логи в самом приложении. Если софт_А работает, а софт_Б - нет - алгоритм очень простой, надо всего лишь подогнать софт_Б под работающий вариант |