Retry for network errors like -101, OnResourceResponse()?

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Retry for network errors like -101, OnResourceResponse()?

Postby HarmlessDave » Fri Aug 17, 2018 12:56 pm

I asked a similar question back in 2015, but I'm not sure if the answer there applies: viewtopic.php?f=6&t=12742&p=24852&hilit=%3AOnLoadError#p24852

I'm not asking about retrying a server error like 500 or 404, I'd like to be able to retry some chromium network errors, in particular -101 = NET_ERROR(CONNECTION_RESET, -101)

OnResourceResponse look like it would let me retry HTTP errors but not errors like -101 since I can only look at the response header not chromium errors. Am I wrong and a header with the network error gets added? (If yes, a sample would be very helpful.)

OnLoadError is missing the request object and has no built-in retry option, so the only way I could see to use it would be to do my own caching of requests for frames in some earlier event, then use that cached request if I want to retry. Can anyone suggest a better approach?
HarmlessDave
Expert
 
Posts: 370
Joined: Fri Jul 11, 2014 2:02 pm

Re: Retry for network errors like -101, OnResourceResponse()

Postby magreenblatt » Fri Aug 17, 2018 1:05 pm

Is your intent to only retry failed frame navigations, or all resource requests that fail? For the latter I would expect a decently written web app to have its own retry logic (if an XHR fails, for example), and you probably shouldn't interfere with that.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Retry for network errors like -101, OnResourceResponse()

Postby HarmlessDave » Fri Aug 17, 2018 1:30 pm

magreenblatt wrote:Is your intent to only retry failed frame navigations, or all resource requests that fail? For the latter I would expect a decently written web app to have its own retry logic (if an XHR fails, for example), and you probably shouldn't interfere with that.


We'd just like to retry failed frame navigations, not other resources or XHR.
HarmlessDave
Expert
 
Posts: 370
Joined: Fri Jul 11, 2014 2:02 pm

Re: Retry for network errors like -101, OnResourceResponse()

Postby magreenblatt » Fri Aug 17, 2018 1:46 pm

What about calling LoadURL(failedUrl) from OnLoadError?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Retry for network errors like -101, OnResourceResponse()

Postby Czarek » Fri Aug 17, 2018 2:45 pm

If there are issues with calling LoadURL inside that callback then try using CefPostTask to call LoadURL, so that it executes after OnLoadError returns.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: Retry for network errors like -101, OnResourceResponse()

Postby HarmlessDave » Fri Aug 17, 2018 3:40 pm

magreenblatt wrote:What about calling LoadURL(failedUrl) from OnLoadError?


If there are issues with calling LoadURL inside that callback then try using CefPostTask to call LoadURL, so that it executes after OnLoadError returns.


Thanks, that should work for a GET request. Is there any way to know just from the passed parameters that the failed request was a GET not a POST? Or a way to get the failed CefRequest so a POST would work too?

Code: Select all
::OnLoadError(CefRefPtr<CefBrowser> browser,
     CefRefPtr<CefFrame> frame,
     ErrorCode errorCode,
     const CefString& errorText,
     const CefString& failedUrl)
HarmlessDave
Expert
 
Posts: 370
Joined: Fri Jul 11, 2014 2:02 pm

Re: Retry for network errors like -101, OnResourceResponse()

Postby Czarek » Fri Aug 17, 2018 8:19 pm

I've tested in cefclient and CefBrowser::Reload doesn't work on POST requests (by using Reload button). Additionally when I use "Back" button I noticed "ERR_CACHE_MISS -400".

It seems caching the request data in OnBeforeBrowse (and using OnBeforeResourceLoad for POST requests, see http://magpcss.org/ceforum/viewtopic.php?f=6&t=15750) is the way to go.

Regarding using CefPostTask I mentioned earlier. In the past if I recall correctly, I've sometimes had crashes when initiating navigation from OnLoadError, that's why I suggested it. It's safer to do it that way.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: Retry for network errors like -101, OnResourceResponse()

Postby HarmlessDave » Sun Aug 19, 2018 5:08 pm

Regarding using CefPostTask I mentioned earlier. In the past if I recall correctly, I've sometimes had crashes when initiating navigation from OnLoadError, that's why I suggested it. It's safer to do it that way.


Thanks, I've had similar glitches trying to do replacement navigations in OnBeforeBrowse after canceling a navigation, so I've used CefPostTask and Windows PostMessage for that before.
HarmlessDave
Expert
 
Posts: 370
Joined: Fri Jul 11, 2014 2:02 pm


Return to Support Forum

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 70 guests