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

Работа с нестабильным каналом или сайтом #148

Closed
MonkAlex opened this issue Nov 17, 2019 · 0 comments · Fixed by #154
Closed

Работа с нестабильным каналом или сайтом #148

MonkAlex opened this issue Nov 17, 2019 · 0 comments · Fixed by #154
Milestone

Comments

@MonkAlex
Copy link
Owner

Сейчас acomics может отдать ошибку на парсинге глав, ошибка при этом решается переповтором.

2019-11-17 14:54:23.0888 4272 24 1.49.0.0 Error ???? ??????????, ??????: https://acomics.ru/~girl-genius/list?skip=1435, ??????? ????? - 0
System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.WebClient.GetWebResponse(WebRequest request, IAsyncResult result)
at MangaReader.Core.Account.CookieClient.GetWebResponse(WebRequest request, IAsyncResult result) in C:\projects\mangareader\MangaReader.Core\Account\CookieClient.cs:line 32
at System.Net.WebClient.DownloadBitsResponseCallback(IAsyncResult result)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
at MangaReader.Core.Services.Page.d__11.MoveNext() in C:\projects\mangareader\MangaReader.Core\Services\Page.cs:line 48
2019-11-17 14:54:23.1201 4272 24 1.49.0.0 Error ????? ?? ??????? ?? ?????? https://acomics.ru/~girl-genius
System.ArgumentNullException: Value cannot be null.
Parameter name: html
at HtmlAgilityPack.HtmlDocument.LoadHtml(String html) in C:\Users\Jonathan\source\repos\HtmlAgilityPack\HtmlAgilityPack.Shared\HtmlDocument.cs:line 783
at Acomics.Parser.d__14.MoveNext() in C:\projects\mangareader\Sites\Acomics.ru\Parser.cs:line 272

Аналогично, h-chan очень тормозит и может выдавать рандомные ошибки, многие из которых решаются переповтором запроса, например:

=> Tests.MangaTest.Download(https://h-chan.me/manga/12850-twisted-intent-chast-1.html)
2019-11-17 15:01:31.8286 4272 19 1.49.0.0 Error System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 163.172.5.177:443
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
at System.Net.WebClient.DownloadData(Uri address)
at Hentaichan.Mangachan.Parser.d__7.MoveNext() in C:\projects\mangareader\Sites\Hentaichan.me\Mangachan\Parser.cs:line 233
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 163.172.5.177:443
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.InternalConnect(EndPoint remoteEP)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.WebClient.DownloadDataInternal(Uri address, WebRequest& request)
at System.Net.WebClient.DownloadData(Uri address)
at Hentaichan.Mangachan.Parser.d__7.MoveNext() in C:\projects\mangareader\Sites\Hentaichan.me\Mangachan\Parser.cs:line 233

Пока идея простая - определить ошибки, которые могут быть решены переповтором, выделить куда-то весь код, который должен уметь повторять запросы и переписать всё связанное.

В целом, это может быть много кода, поэтому делать надо в отдельном PR и по возможности - добавить тестов.
Отдельное внимание к циклам, в идеале запрос не должен попадать в двойной цикл (сам делает переповторы, а потом сверху кто-то делает переповторы без изменений).

@MonkAlex MonkAlex added this to the Deffered milestone Nov 17, 2019
@MonkAlex MonkAlex modified the milestones: Deffered, 1.50 Nov 27, 2019
@MonkAlex MonkAlex linked a pull request Apr 30, 2020 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant