kaazing / http2-cache.js

2 stars 11 forks source link

add Config for removing proxy config on failure and retry xhr requests that were pending to origin instead #101

Closed hthetiot closed 6 years ago

hthetiot commented 6 years ago

Overview

The goal is to fall-back the pending XHR requests there were waiting for the proxy connection (configuration emit completed) to origin server by removing the proxy config on connection failure and add it on reconnection success (transport response open).

Example:

Current (reconnectAuto: true and reconnectAutoDelay of 100ms * perReconnectFailureAttempt )

   {  
       "push": "optional-path-that-is-opened-for-pushes",
       "transport": "wss://where-the-underlying-ws-transport-connects:443/",
       "reconnectAutoDelay": 100,
       "reconnectAuto": true,
       "proxy":[  
          "http://origin-to-send-via-http2:80/path/",
          "http://origin-to-send-via-http2:80/path2/",
          "http://other-origin-to-send-via-http2:80"
       ]
    }

New Options accelerationStrategyand maximumReconnectInterval

Will pursue reconnection attempt per reconnectAutoDelay interval but trigger completed on failure when true for pending XHR to procced.

   {  
       "push": "optional-path-that-is-opened-for-pushes",
       "transport": "wss://where-the-underlying-ws-transport-connects:443/",
       "accelerationStrategy": "connected",
       "maximumReconnectInterval": 4000,
       "reconnect": true,
       "proxy":[  
          "http://origin-to-send-via-http2:80/path/",
          "http://origin-to-send-via-http2:80/path2/",
          "http://other-origin-to-send-via-http2:80"
       ]
    }

Entry points:

dpwspoon commented 6 years ago

I would think better terminology might be:

maximumReconnectInterval: 4000,
accelerationStrategy: "always"  or "connected"

accelerationStrategy states when do you accelerate URLs.

Value always means always/don't make requests if they are proxied but no ws connection is open. Wait for the connection to open instead.

Value connected means make requests when connected via websocket.

I don't think we need "reconnectAuto": true, As this should always be true. Is there some usecase to set this as false?

Note, this does change existing properties, but I think it would be best to do a sweeping change now as were are now adding a feature that makes it likely the other values will actually be needed.

hthetiot commented 6 years ago

I don't think we need "reconnectAuto": true, As this should always be true. Is there some usecase to set this as false?

This can be really useful to debug initial connection failure instead of having the logs always trying to reconnect.