org.eclipse.rap icon indicating copy to clipboard operation
org.eclipse.rap copied to clipboard

Handling network connection error with SeverPush active

Open nzanaga opened this issue 2 years ago • 7 comments

I suppose that not all exceptions are handled when using 'Request_sendWithFetch' , I found problems when 'ServerPush' is active, sometimes retry is working and sometimes no.

I have modified "Request_sendWithFetch" adding try .. catch inside entire function and inside every 'then' and it seems to work fine.

This is, for example, an uncaught error:

image

nzanaga avatar Jan 23 '23 18:01 nzanaga

Can you tell some simple steps to reproduce the issue?

ifurnadjiev avatar Jan 24 '23 06:01 ifurnadjiev

What action did you perform in order to provoke ERR_CONNECTION_RESET error?

ifurnadjiev avatar Jan 24 '23 10:01 ifurnadjiev

BTW... which RAP version is used for your testing?

ifurnadjiev avatar Jan 24 '23 11:01 ifurnadjiev

I'm using 3.24.0-M1 version

For testing I do:

  • start a RAP application on my pc (windows 10)
  • start a virtual machine with "Oracle VM VirtualBox" (windows 10)
  • from virtual machine open Edge (or Chrome or Firefox) browser and point to host machine
  • while application is running and browser is open, disable / enable virtual machine network card reply this action many times and each time keep network disabled for few time or long time
    while the network is disabled try both without doing anything on the browser and by performing activities on the browser (making the error message appear immediately)

I have done some tests, with PushSession active or not, and watching the error on the browser console I see the error is not always the same, the most commons are: net::ERR_ADDRESS_UNREACHABLE net::ERR_INTERNET_DISCONNECTED net::ERR_CONNECTION_RESET

and sometimes also the error above.

To do a better test, I also have increase 'ServerPush.js' retry time to prevent error message box from popping up too soon (by the way I think ServerPush should be do a continuos call without break with message if user do nothing while network is down)

Here the modified code in 'ServerPush.js' '_handleError'

  if( this._retryCount < 1000 ) {
	this._retryCount++;  
    var delay = (this._retryCount <= 5) ? 1000 : 3000;
    rwt.client.Timer.once( this.sendServerPushRequest, this, delay );
  } else {
    this._handleConnectionError();
  }

nzanaga avatar Jan 24 '23 14:01 nzanaga

Could you try tomorrow with the RAP nightly build. I fixed the other two issues reported by you and I think that they are related.

ifurnadjiev avatar Jan 24 '23 15:01 ifurnadjiev

In "Request.js" method "_sendWithFetch" there is a ".catch" only in the first ".then" command

Should be added ".catch" after every ".then" to prevent uncaught errors

nzanaga avatar Jan 26 '23 09:01 nzanaga

I don't think this is needed. The outer ".catch" should catch all the errors thrown internally by "fetch" and ".then". More over the second Promise is for getting the response text which should never throw.

ifurnadjiev avatar Jan 26 '23 11:01 ifurnadjiev