Stomp Client never receives the backend messages using Google Chrome throttling / bad internet
See original GitHub issueFirst of all, only Google Chrome seems to be affected by this issue, only with unstable internet connection or throttling. Firefox and even browsers based on Chromium work fine (Vivaldi, Edge).
Reproduction
- open Google Chrome, I have used version 97.0.4692.71 (both Windows and Mac OS)
- turn on throttling (3G slow / 3G fast)
- connect to server
- listen to messages incoming from BE
- send message from BE
- message is never caught
However if you try to send message from client to server, this will work fine: BE receives it with all necessary data. Here is an example of communication:
If I turn off throttling the output is as we expect:
Implementation details
On the BE side we use Spring Messaging implementation of STOMP (v 5.1.9), client side we have tried using STOMP both over SockJS and Websocket, StompJS version 5.4.2 and the latest one.
Here is an example of client for reproduction:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://cdn.jsdelivr.net/npm/sockjs-client@1/dist/sockjs.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/stomp.js/2.3.3/stomp.min.js" integrity="sha512-iKDtgDyTHjAitUDdLljGhenhPwrbBfqTKWO1mkhSFH3A7blITC9MhYon6SjnMhp4o0rADGw9yAC6EW4t5a4K3g==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<title>Document</title>
</head>
<body>
<button onclick="sendMessage()">Click here to send a message</button>
<script>
var sock = new WebSocket('ws://localhost:5000/ws');
var stompClient = Stomp.over(sock);
stompClient.connect({}, function(frame) {
stompClient.subscribe('/user/topic/msm/json', function (msg) {
console.log("subscribe USER");
console.log(msg);
});
stompClient.subscribe('/topic/msm/json', function (msg) {
console.log("subscribe GLOBAL");
console.log(msg);
});
});
function sendMessage() {
stompClient.send('/request/json/bean/INVOKE', {}, JSON.stringify({"path":"/main/index.html","payload":{},"elements":null,"actionId":"5dfa0accd38f","eventType":"USER","scope":"PROTOTYPE","beanId":"translationServiceImpl","functionName":"getTranslation","args":[{"0":"RemoveFavoriteItem","1":"translationsRepository"}]}));
}
</script>
</body>
</html>
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Network Throttling in Chrome DevTools - DebugBear
In order to throttle the network, first open Chrome DevTools. Now you can observe the website being loaded on a slow connection. Check...
Read more >spring boot - Detect websocket connection break on internet ...
Is there any way to get an exception inside handleTransportError method on internet connection loss or socket disconnection? public class ...
Read more >How to perform Network Throttling in Chrome - BrowserStack
Method 1: Network Simulation Using Chrome DevTools To use the network throttler in Chrome: Open Chrome DevTools. Navigate to the Network Tab ......
Read more >The Definitive Guide to HTML5 WebSocket
We will show you how to implement a WebSocket client in your web application, create your own WebSocket server, use WebSocket with higher-level...
Read more >sgcWebSockets 2022.10 - eSeGeCe
WhatsApp Receive Messages and Status Notifications. ... WebSockets represent a long-awaited evolution in client/server web technology.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I posted today a bug report in Chrome Browser and Opera Browser.
Then I did some tests again in both browsers. In the Chrome Browser seems it’s fixed, I haven’t managed to reproduce this issue. But in the Opera Browser still facing this issue.
We have tried with the latest version of StompJS, it’s the same thing, it’s not working on slow networks as well.
I would say this is not about only throttled mode in Chrome. Some clients which have poor internet connection facing with this issue in most popular browsers, like Chrome, Safari, Opera.
We did some tests on the different browsers as well and we have managed to get this code works only in Chrome Canary build and Firefox all kinds of builds.