-
Notifications
You must be signed in to change notification settings - Fork 166
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
[Spike] Pre-requisite for fault-tolerant client-server #20418
Comments
Cases seen in reported logs:
|
As the server always answers the client, the client should probably queue the sends as it does for one single pushPendingMessage when using bidirectional transport, but not for xhr. Also |
@caalador has covered the majority of cases. Let me just extend it a bit.
|
Tickets created based on the analysis above and other older tickets (in priority):
|
For testing I'd propose to not use any heavy third-party tools, but instead to intercept the request/response right away in a Vaadin applications.
An example: import org.atmosphere.config.managed.AtmosphereInterceptorAdapter;
import org.atmosphere.cpr.AtmosphereResource;
import org.atmosphere.cpr.AtmosphereResponse;
import org.atmosphere.cpr.AtmosphereRequest;
public class CustomWebSocketInterceptor extends AtmosphereInterceptorAdapter {
@Override
public Action inspect(AtmosphereResource resource) {
AtmosphereRequest request = resource.getRequest();
// Intercept client-to-server messages
String clientMessage = request.getReader().lines()
.reduce("", (accumulator, actual) -> accumulator + actual);
// Simulate dropping a message from the client
if (clientMessage.contains("something")) {
return Action.CANCELLED; // Stops further processing
}
return Action.CONTINUE;
}
@Override
public void postInspect(AtmosphereResource resource) {
AtmosphereResponse response = resource.getResponse();
// Intercept server-to-client messages
String serverMessage = response.toString();
// Simulate altering a response message
if (serverMessage.contains("something")) {
String modifiedMessage = serverMessage.replace("something", "MODIFIED");
response.write(modifiedMessage);
}
}
@Override
public void destroy() {
// Cleanup if needed
}
} Then declare the interceptor in <atmosphere-handlers>
<mapping path="/*" support-session="true" broadcaster-cache="org.atmosphere.cache.UUIDBroadcasterCache">
<interceptor>com.example.CustomWebSocketInterceptor</interceptor>
</mapping>
</atmosphere-handlers> What this can give us:
@WebFilter("/*")
public class NetworkSimulatingFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
// Simulate network delay
Thread.sleep(500);
// Randomly drop requests
if (Math.random() < 0.1) { // 10% chance to drop
((HttpServletResponse) response).sendError(HttpServletResponse.SC_GATEWAY_TIMEOUT, "Simulated timeout");
return;
}
// Proceed normally
chain.doFilter(request, response);
}
} To intercept the Vaadin requests in browser, the following hack for (function() {
const originalFetch = window.fetch;
window.fetch = function(...args) {
console.log('Intercepted request:', args);
// Simulate a network failure
if (args[0].includes('some-endpoint')) {
return Promise.reject(new Error('Simulated network error'));
}
return originalFetch.apply(this, args).then(response => {
console.log('Intercepted response:', response);
// Optionally, clone and modify the response
if (response.url.includes('another-endpoint')) {
return response.text().then(body => {
const modifiedBody = body.replace('original-content', 'modified-content');
return new Response(modifiedBody, response);
});
}
return response;
});
};
})(); |
Describe your motivation
This is a pre-requisite investigation task before we can start #20348.
The description there is not enough to start the development and it costs too many story points from the team's opinion, thus needs a decomposition.
The outcome of this investigation should be:
The text was updated successfully, but these errors were encountered: