Closed bubnenkoff closed 5 years ago
привет а как ты обрабатываешь этот ексепшн?
2019-02-08T18:11:09.209:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:serverResponse:193 Failed to read response from server
@ikod а разве Access Violation можно как-то обработать?
А я про другое сообщение об ошибке failed to read response
сб, 9 февр. 2019 г., 13:04 Dmitry Bubnenkov notifications@github.com:
@ikod https://github.com/ikod а разве Access Violation можно как-то обработать?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ikod/dlang-requests/issues/93#issuecomment-462034783, or mute the thread https://github.com/notifications/unsubscribe-auth/ABNuSZUyLa-JchTDVZGly7X0y9F9Uashks5vLqsggaJpZM4awLTJ .
@ikod я никак его не обрабатываю. Имеет смысл его ловить? Просто какой сценарий может быть? Вот поймал я его и еще раз запрос пытаться сделать?
Пока закрою т.к. есть вероятность, что это мой код кинул, а не твоя либа.
Нет. Все равно падает. Вот код. my.zip source.zip
Если вдруг у тебя будет возможность запустить у себя я прикрепил sqlite БД источника откуда данные загружаются и папку source. Для доступа к SQLite Использую либу Адама Роупа
https://gist.github.com/run-dlang/42194aa9518e3d722eb580a1d942467c
Вот падение. Не могу понять причем тут может быть запись в файл...
Мне тут подсказывают, что это может быть баг где-то внутри ассоциативных массивов (если они у тебя используются). Или возможно оно получает пустой ответ (не ясно почему) и падает при записи пустоты. Короче сейчас сам постараюсь собрать больше информации.
Попробовал я сдеать так. И дождаться когда упадет.
writeln("length data: ", rs.responseBody.data.length);
Упало и ничего не вывело.
Привет!
Включи плиз дебаг в той программе которая падает (компилируй вместе с -debug=requests) и пришли мне вывод, только не в виде скриншота, а текстом.
@ikod dub по умолчанию собирает дебаг версию.
rq.authenticator = new BasicAuthentication(ftp_login, ftp_pass);
rq.verbosity = 2; // добавил строку
Такой режим тебе подойдет?
Ещё нужен globalLogLevel = LogLevel.trace;
вт, 12 февр. 2019 г., 17:45 Dmitry Bubnenkov notifications@github.com:
@ikod https://github.com/ikod dub по умолчанию собирает дебаг версию.
rq.authenticator = new BasicAuthentication(ftp_login, ftp_pass);
rq.verbosity = 2; // добавил строку
Такой режим тебе подойдет?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ikod/dlang-requests/issues/93#issuecomment-462811308, or mute the thread https://github.com/notifications/unsubscribe-auth/ABNuSYrm5zt0cIxdGnk9XtBjwihEr0cTks5vMuGngaJpZM4awLTJ .
@ikod быть может я что-то не так сделал, но у меня лог действий не сильно изменился. Я тут заметил, что первый архив оно отрабатывает нормально, а при попытке скачать второй скачивает файл с нулевым размером и падает с указанной ошибкой. Может я где-то объект подключения не так использую? Сейчас еще сам посмотрю.
Все я кажется разобрался в чем проблема. Для каждого загружаемого файла повторно создавался объект подключения:
rq.authenticator = new BasicAuthentication(ftp_login, ftp_pass);
Все решилось переносом этой строки в main из функции скачивания.
Можно ли этого было как-то избежать? Т.е. инами словами это ожидаемое поведение? Или оно не должно было все же падать?
Блин не помогло, снова падает
@bubnenkoff
так что с логами? пока некуда смотреть
@ikod блин сори, тут просто работы дофига. Смотри.
Request rq;
Response rs;
void main()
{
globalLogLevel(LogLevel.trace);
rq.authenticator = new BasicAuthentication(ftp_login, ftp_pass);
rq.verbosity = 2;
....
}
Этого же достаточно чтобы логи писались в нужном тебе виде?
@ikod блин сори, тут просто работы дофига. Смотри.
Request rq; Response rs; void main() { globalLogLevel(LogLevel.trace); rq.authenticator = new BasicAuthentication(ftp_login, ftp_pass); rq.verbosity = 2; .... }
Этого же достаточно чтобы логи писались в нужном тебе виде?
плюс сборка с -debug=requests - да, этого достаточно
@ikod запустил, минут через 20 думаю упадет и скину то что получилось.
@ikod
D:\code\2018\ftp_walker\ftp_walker.exe
arhive for processing: /fcs_regions/Moskva/contracts/currMonth/contract_Moskva_2019020600_2019020700_002.xml.zip
downloadFile
ftp_arhive_path: ftp://ftp.zakupki.gov.ru/fcs_regions/Moskva/contracts/currMonth/contract_Moskva_2019020600_2019020700_002.xml.zip
2019-02-14T12:29:35.020:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\streams.d:connect:1000 Create connection to ftp.zakupki.gov.ru:21
2019-02-14T12:29:35.027:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\streams.d:connect:1009 Trying 31.41.245.53:21
2019-02-14T12:29:35.040:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\streams.d:connect:1019 Connected to 31.41.245.53:21
2019-02-14T12:29:35.042:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:serverResponse:180 Wait on control channel< 220 (vsFTPd 2.2.2)
2019-02-14T12:29:35.049:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:get:450 Server initial response: 220 (vsFTPd 2.2.2)
2019-02-14T12:29:35.052:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:get:465 Use free:f--- as username:password2019-02-14T12:29:35.054:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:sendCmdGetResponse:148 cmd to server: USER free
> USER free
2019-02-14T12:29:35.056:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:serverResponse:180 Wait on control channel< 331 Please specify the password.
2019-02-14T12:29:35.065:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:sendCmdGetResponse:148 cmd to server: PASS free
> PASS free
2019-02-14T12:29:35.067:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:serverResponse:180 Wait on control channel< 230 Login successful.
2019-02-14T12:29:35.086:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:sendCmdGetResponse:148 cmd to server: PWD
> PWD
2019-02-14T12:29:35.088:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:serverResponse:180 Wait on control channel< 257 "/"
2019-02-14T12:29:35.096:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:sendCmdGetResponse:148 cmd to server: CWD fcs_regions/Moskva/contracts/currMonth
> CWD fcs_regions/Moskva/contracts/currMonth
2019-02-14T12:29:35.098:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:serverResponse:180 Wait on control channel< 250 Directory successfully changed.
2019-02-14T12:29:35.106:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:sendCmdGetResponse:148 cmd to server: TYPE I
> TYPE I
2019-02-14T12:29:35.108:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:serverResponse:180 Wait on control channel< 200 Switching to Binary mode.
2019-02-14T12:29:35.116:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:sendCmdGetResponse:148 cmd to server: SIZE contract_Moskva_2019020600_2019020700_002.xml.zip
> SIZE contract_Moskva_2019020600_2019020700_002.xml.zip
2019-02-14T12:29:35.118:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:serverResponse:180 Wait on control channel< 213 6683766
2019-02-14T12:29:35.126:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:sendCmdGetResponse:148 cmd to server: PASV> PASV
2019-02-14T12:29:35.127:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:serverResponse:180 Wait on control channel< 227 Entering Passive Mode (31,41,245,53,117,134).
2019-02-14T12:29:35.135:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\streams.d:connect:1000 Create connection to 31.41.245.53:30086
2019-02-14T12:29:35.137:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\streams.d:connect:1009 Trying 31.41.245.53:300862019-02-14T12:29:35.147:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\streams.d:connect:1019 Connected to 31.41.245.53:30086
2019-02-14T12:29:35.148:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:sendCmdGetResponse:148 cmd to server: RETR contract_Moskva_2019020600_2019020700_002.xml.zip
> RETR contract_Moskva_2019020600_2019020700_002.xml.zip
2019-02-14T12:29:35.149:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:serverResponse:180 Wait on control channel< 150 Opening BINARY mode data connection for contract_Moskva_2019020600_2019020700_002.xml.zip (6683766 bytes).
2019-02-14T12:29:35.189:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:get:588 got 16384 bytes from data channel
2019-02-14T12:29:35.192:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:get:588 got 15816 bytes from data channel
2019-02-14T12:29:35.193:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:get:588 got 1400 bytes from data channel
2019-02-14T12:29:35.200:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:get:588 got 8400 bytes from data channel
2019-02-14T12:29:35.203:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:get:588 got 16384 bytes from data channel
2019-02-14T12:29:35.205:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:get:588 got 3216 bytes from data channel
2019-02-14T12:29:35.207:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:get:588 got 9800 bytes from data channel
2019-02-14T12:29:35.209:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:get:588 got 14000 bytes from data channel
2019-02-14T12:29:35.210:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:get:588 got 11200 bytes from data channel
2019-02-14T12:29:35.212:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:get:588 got 4200 bytes from data channel
2019-02-14T12:29:36.238:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\streams.d:close:981 Close socket
2019-02-14T12:29:36.239:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:serverResponse:180 Wait on control channel< 226 Transfer complete.
2019-02-14T12:29:36.248:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:get:657 Successfully received 6683766 bytes
2019-02-14T12:29:36.250:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\streams.d:close:981 Close socket
2019-02-14T12:29:36.252:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:sendCmdGetResponse:148 cmd to server: CWD /
> CWD /
2019-02-14T12:29:36.254:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:serverResponse:180 Wait on control channel< 250 Directory successfully changed.
archive_path: D:\code\2018\ftp_walker/files/contract_Moskva_2019020600_2019020700_002.xml.zip
length data: 6683766
42736 f9a256bf contract_2770967919116000141_47911308.xml
xml_full_path: D:\code\2018\ftp_walker/files/contract_Moskva_2019020600_2019020700_002/contract_2770967919116000141_47911308.xml
python D:\code\2018\zakupki-downloader\source2\main.py D:\code\2018\ftp_walker/files/contract_Moskva_2019020600_2019020700_002/contract_2770967919116000141_47911308.xml contracts Moskva
DONE
count: 616 total: 617
arhive for processing: /fcs_regions/Moskva/contracts/currMonth/contract_Moskva_2019020600_2019020700_003.xml.zip
downloadFile
ftp_arhive_path: ftp://ftp.zakupki.gov.ru/fcs_regions/Moskva/contracts/currMonth/contract_Moskva_2019020600_2019020700_003.xml.zip
2019-02-14T12:38:51.707:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:sendCmdGetResponse:148 cmd to server: PWD > PWD
2019-02-14T12:38:51.709:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:serverResponse:180 Wait on control channel< 421 Timeout.
2019-02-14T12:38:51.711:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:sendCmdGetResponse:148 cmd to server: CWD fcs_regions/Moskva/contracts/currMonth
> CWD fcs_regions/Moskva/contracts/currMonth
2019-02-14T12:38:51.713:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:serverResponse:180 Wait on control channel2019-02-14T12:38:51.714:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:serverResponse:193 Failed to read response from server
[ERROR] FAILED request to FTP
archive_path: D:\code\2018\ftp_walker/files/contract_Moskva_2019020600_2019020700_003.xml.zip
object.Error@(0): Access Violation
----------------
0x0040483B in void app.downloadFile(immutable(char)[], immutable(char)[], immutable(char)[], int) at D:\code\2018\ftp_walker\source\app.d(317)
0x00404596 in void app.extractFromDBAndProcess() at D:\code\2018\ftp_walker\source\app.d(263)
0x004038EB in _Dmain at D:\code\2018\ftp_walker\source\app.d(98)
0x004AAF2B in void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll().__lambda1()
0x004AAEAD in void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll()
0x004AAD46 in _d_run_main
0x0044E6EC in main at D:\code\2018\ftp_walker\source\arsd\sqlite.d(7)
0x005095AD in mainCRTStartup
0x75EB8484 in BaseThreadInitThunk
0x77B13AB8 in RtlAreBitsSet
0x77B13A88 in RtlAreBitsSet
0x77B1AA3C in ZwAllocateVirtualMemory
Program exited with code 1
Походу таймаут подключения случается.
вот же где проблема:
0x0040483B in void app.downloadFile(immutable(char)[], immutable(char)[], immutable(char)[], int) at D:\code\2018\ftp_walker\source\app.d(317)
чт, 14 февр. 2019 г. в 11:51, Dmitry Bubnenkov notifications@github.com:
Походу таймаут подключения случается.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ikod/dlang-requests/issues/93#issuecomment-463563767, or mute the thread https://github.com/notifications/unsubscribe-auth/ABNuSXaQEfhY1A5k7IT94q-1XJGG-qfHks5vNTGugaJpZM4awLTJ .
@ikod не мог бы пояснить в чем проблема и как ее можно решить?
не видя приложения - невозможно. но к библиотеке это вряд-ли имеет отношение
@ikod а точно не может быть проблема с таймаутом подключения? Просто у меня тут открыт FTP клиент рядом. Через n-минут файлы в нем становятся серым. Надо понимать, что подключение закрывается. Хотя я точно не уверен.
Подскажи в каком месте мне имеет смысл подключение проверять\делать повторно? И как его делать? Создавать заново обект request?
https://gist.github.com/run-dlang/290b53c4d21235785838ff0207840ef7
И если можешь укажи на любые косяки связанные с тем как я использую твою библиотеку.
смотри что там делается:
0x0040483B in void app.downloadFile(immutable(char)[], immutable(char)[], immutable(char)[], int) at D:\code\2018\ftp_walker\source\app.d(317)
я не вижу что в этом коде, поэтому больше ничего сказать не могу
@ikod а ссылка выше?... там же полный исходник
f.rawWrite(rs.responseBody.data); // падает тут
а ты проверяешь код возврата в rs? Может никакого ResponseBody нет а ты его пытаешься сохранять
чт, 14 февр. 2019 г. в 15:18, Dmitry Bubnenkov notifications@github.com:
@ikod https://github.com/ikod а ссылка выше?... там же полный исходник
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ikod/dlang-requests/issues/93#issuecomment-463623365, or mute the thread https://github.com/notifications/unsubscribe-auth/ABNuSRZau5Veb2t48Why8kQVjdHuOCbBks5vNWIMgaJpZM4awLTJ .
@ikod очень здравая идея, а в какой ситуации такое может произойти? Сейчас попробую.
Такой вариант проверки вообще адекватен:
File f = File(archive_path, "wb");
if (rs.code == 226)
f.rawWrite(rs.responseBody.data); // потенциальное падение на пустых данных
f.close();
Код ответа сервера глянул. Вроде бы 226 тот что нужен. Ну или как минимум на первом файле он возвращается. ?
если rs.code/100 >= 3 можешь считать что там ошибка
чт, 14 февр. 2019 г. в 16:12, Dmitry Bubnenkov notifications@github.com:
Такой вариант проверки вообще адекватен:
File f = File(archive_path, "wb"); if (rs.code == 226) f.rawWrite(rs.responseBody.data); // потенциальное падение на пустых данных f.close();
Код ответа сервера глянул. Вроде бы 226 тот что нужен. Ну или как минимум на первом файле он возвращается. ?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ikod/dlang-requests/issues/93#issuecomment-463641309, or mute the thread https://github.com/notifications/unsubscribe-auth/ABNuSdcKTn5TcDSg514aEqVhnLflLLAfks5vNW7pgaJpZM4awLTJ .
Продолжает падать:
0x00404797 in void app.downloadFile(immutable(char)[], immutable(char)[], immutable(char)[], int) at D:\code\2018\ftp_walker\source\app.d(303)
...
ftp_arhive_path: ftp://ftp.zakupki.gov.ru/fcs_regions/Moskva/notifications/currMonth/notification_Moskva_2019020600_2019020700_007.xml.zip
2019-02-14T17:33:09.235:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:sendCmdGetResponse:148 cmd to server: PWD
> PWD
0x00404797 in void app.downloadFile(immutable(char)[], immutable(char)[], immutable(char)[], int) at D:\code\2018\ftp_walker\source\app.d(303)
Кусок кода:
try // потенциальное падение. Пофиг если упало
{
writeln("ftp_arhive_path: ", ftp_arhive_path);
rs = rq.get(ftp_arhive_path); // вот у меня 303 строка, но
}
Я просто перед записью добавил проверку кода ответа, но тут до записи определенно не доходит.
@ikod я подготовил минимальный пример который у меня на третьем файле выпадает с ошибкой. Текст ошибки:
object.Error@(0): Access Violation
----------------
0x00426F9D in int requests.streams.SocketStream.send(const(void)[]) at C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\streams.d(1036)
0x0041AE8F in ushort requests.ftp.FTPRequest.sendCmdGetResponse(immutable(char)[], requests.streams.NetworkStream) at C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d(153)
0x0041CA2E in requests.ftp.FTPResponse requests.ftp.FTPRequest.get(immutable(char)[]) at C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d(484)
0x0041DD04 in requests.ftp.FTPResponse requests.ftp.FTPRequest.execute(requests.request.Request) at C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d(680)
0x004100D7 in requests.base.Response requests.request.Request.LastInterceptor.opCall(requests.request.Request, requests.request.RequestHandler) at C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\request.d(496)
0x0041E4AE in requests.base.Response requests.request.RequestHandler.handle(requests.request.Request) at C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\request.d(184)
0x00410A46 in requests.base.Response requests.request.Request.execute(immutable(char)[], immutable(char)[], std.typecons.Tuple!(immutable(char)[], "key", immutable(char)[], "value").Tuple[]) at C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\request.d(600)
0x00410322 in requests.base.Response requests.request.Request.get(immutable(char)[], std.typecons.Tuple!(immutable(char)[], "key", immutable(char)[], "value").Tuple[]) at C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\request.d(529)
0x0040262C in void app.downloadFile(immutable(char)[]) at D:\bug_test\source\app.d(69)
0x00402553 in _Dmain at D:\bug_test\source\app.d(49)
0x0047F6B7 in void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll().__lambda1()
0x0047F639 in void rt.dmain2._d_run_main(int, char**, extern (C) int function(char[][])*).runAll()
0x0047F4D2 in _d_run_main
0x0040F614 in main at D:\bug_test\source\app.d(7)
0x004D9DDD in mainCRTStartup
0x75EB8484 in BaseThreadInitThunk
0x77B13AB8 in RtlAreBitsSet
0x77B13A88 in RtlAreBitsSet
0x77B1AA3C in ZwAllocateVirtualMemory
Program exited with code 1
Не мог бы у себя запустить и сказать падает ли оно у тебя или нет.
да, смотрю
@bubnenkoff падение воспроизводится, но мне нужно еще время для разборок.
Вроде же уже писал что нет смысла работать с ответом если произошел exception или код ответа больше чем 226. А ты ловишь exception но продолжаешь пытаться работать с неопределенными данными.
@ikod видимо это реально мой косяк. Закрываю тикет.
Вот самый последний код:
import std.stdio;
import std.array;
import std.conv;
import std.string;
import std.path;
import std.file;
import requests;
import core.time : days;
import std.datetime;
import std.algorithm;
import std.range;
import core.thread;
import std.experimental.logger;
string ftp_url = "ftp.zakupki.gov.ru";
string ftp_login = "free";
string ftp_pass = "free";
Request rq;
Response rs;
string [] ftp_urls = ["ftp://ftp.zakupki.gov.ru/fcs_regions/Moskva/notifications/notification_Moskva_2014030100_2014040100_20140707115823_221.xml.zip",
"ftp://ftp.zakupki.gov.ru/fcs_regions/Moskva/notifications/notification_Moskva_2014030100_2014040100_20140707115823_222.xml.zip",
"ftp://ftp.zakupki.gov.ru/fcs_regions/Moskva/notifications/notification_Moskva_2014030100_2014040100_20140707115823_223.xml.zip",
"ftp://ftp.zakupki.gov.ru/fcs_regions/Moskva/notifications/notification_Moskva_2014030100_2014040100_20140707115823_226.xml.zip",
"ftp://ftp.zakupki.gov.ru/fcs_regions/Moskva/notifications/notification_Moskva_2014030100_2014040100_20140707115823_227.xml.zip",
"ftp://ftp.zakupki.gov.ru/fcs_regions/Moskva/notifications/notification_Moskva_2014020100_2014030100_126.xml.zip"];
void main()
{
globalLogLevel(LogLevel.trace);
rq.authenticator = new BasicAuthentication(ftp_login, ftp_pass);
rq.verbosity = 2; // добавил строку
writeln(thisExePath());
foreach(file; ftp_urls)
{
downloadFile(file);
}
}
void downloadFile(string full_file_path )
{
string files_folder = dirName(thisExePath()) ~ `/files/`;
writeln("downloadFile");
if(!exists("files"))
{
auto dir = "files";
dir.mkdir;
}
string archive_path = files_folder ~ baseName(full_file_path);
try // потенциальное падение.
{
writeln("downloading url: ", full_file_path);
writeln("archive_path: ", archive_path);
rs = rq.get(full_file_path);
writeln("rs.code: ", rs.code);
if(rs.code == 226)
{
writeln("archive_path: ", archive_path);
writeln("code ... ", rs.code);
writeln("length ... ", rs.responseBody.data.length);
File f = File(archive_path, "wb");
f.rawWrite(rs.responseBody.data); // падает вероятно тут
f.close();
}
}
catch (Exception e)
{
Thread.sleep(1.seconds);
writeln("[ERROR] FAILED request to FTP");
}
writeln("downloading ...");
writeln("end download ... ", archive_path);
if(!archive_path.exists)
{
writeln("file do not exists");
if(getSize(archive_path) < 256)
writeln("File too small and deleted: ", archive_path);
}
writeln("sleeping...");
Thread.sleep(360.seconds); // эмуляция обрабобтки
}
В логах я вижу:
archive_path: D:\bug_test/files/notification_Moskva_2014030100_2014040100_20140707115823_222.xml.zip
> PWD
< 421 Timeout.
> CWD fcs_regions/Moskva/notifications
2019-02-20T17:42:22.454:C:\Users\bubnenkov\AppData\Local\dub\packages\requests-1.0.5\requests\source\requests\ftp.d:serverResponse:193 Failed to read response from server
[ERROR] FAILED request to FTP
Как я понимаю все же происходит таймаут подключения. Сервер видимо коннекшен разрывает. Не мог бы сказать как это можно исправить?
@bubnenkoff
а как ты это исправишь? никак - сервер разовал соединение, значит нужно пробовать снова. Раз у тебя долгая обработка между запросам - зачем держать Request? Убери его из глобальной видимости и внеси его создание вовнутрь try:
try
{
auto rq = Request();
rq.authenticator = new BasicAuthentication(ftp_login, ftp_pass);
rq.verbosity = 2;
rq.get();
...
}
catch
{
...
}
А было бы правильно если бы ты в случае таймаута исключение кидал? Такое возможно?
Чтобы просто потом люди на эту же ошибку не напарывались и ее проще отловить было бы
ср, 20 февр. 2019 г. в 18:09, ikod notifications@github.com:
@bubnenkoff https://github.com/bubnenkoff
а как ты это исправишь? никак - сервер разовал соединение, значит нужно пробовать снова. Раз у тебя долгая обработка между запросам - зачем держать Request? Убери его из глобальной видимости и внеси его создание вовнутрь try:
try { auto rq = Request(); rq.authenticator = new BasicAuthentication(ftp_login, ftp_pass); rq.verbosity = 2; rq.get(); ... } catch { ... }
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ikod/dlang-requests/issues/93#issuecomment-465617120, or mute the thread https://github.com/notifications/unsubscribe-auth/AGNmljBBu7yQgNasp74Et0IMQITT1IJhks5vPWUhgaJpZM4awLTJ .
разве ты не получаешь исключение? Откуда у тебя берётся в выводе "[ERROR] FAILED request to FTP"? Плиз зазберись в своём коде, закрываю ишью.
Привет, я тут продолжаю использовать твою либу для загрузки данных с гос-закупок. Примерно через 10 минут загрузки файлов выпадает следующая ошибка:
Как я понимаю дело в твоей либе, а не в sqlite. Возможно она у тебя должна была бы исключение кидать, а не падать с
object.Error@(0): Access Violation