Comments (3)
There is a specific sequence during STOMP disconnect. This library follows that sequence. So, not sure why this error is generated.
If you want to disconnect by closing the underlying WebSocket without going through the shutdown sequence, there a method - https://stomp-js.github.io/api-docs/latest/classes/Client.html#forceDisconnect. This was added to simulate error cases for test cases.
Just calling forceDisconnect
will schedule reconnect. So, you would need to call Client.deactivate
as well.
Please see if it works for you.
from stompjs.
Thanks for clarifying.
I had missed the forceDisconnect. It looks like it is working fine.
In the meantime I had also found a workaround on the server side (as it appears to be a server side bug) for spring users stranding here:
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.socket.TextMessage;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.WebSocketMessage;
import org.springframework.web.socket.WebSocketSession;
import org.springframework.web.socket.handler.WebSocketHandlerDecorator;
public class CustomWebSocketHandlerDecorator
extends WebSocketHandlerDecorator {
private static final Logger logger = LoggerFactory.getLogger(CustomWebSocketHandlerDecorator.class);
public CustomWebSocketHandlerDecorator(WebSocketHandler delegate) {
super(delegate);
}
@Override
public void handleMessage(final WebSocketSession session, final WebSocketMessage<?> message)
throws Exception {
if (message instanceof TextMessage) {
TextMessage msg = (TextMessage) message;
String payload = msg.getPayload();
if (payload.contains("DISCONNECT")) {
logger.info("ignore disconnect frame to avoid double disconnect: {}", message);
return;
}
}
super.handleMessage(session, message);
}
}
and register it with your websocket:
@Configuration
@EnableJms
@EnableWebSocketMessageBroker
public class WebSocketConfig
extends AbstractWebSocketMessageBrokerConfigurer {
@Override
public void configureWebSocketTransport(WebSocketTransportRegistration registration) {
registration.addDecoratorFactory(CustomWebSocketHandlerDecorator::new);
}
....
}
The issue is resolved for me with this. :-)
from stompjs.
Good to know that it works for you. However, I am not sure if it is correct handling as per STOMP protocol specifications (https://stomp.github.io/stomp-specification-1.2.html#DISCONNECT).
from stompjs.
Related Issues (20)
- Failed to compile HOT 8
- Still seeing retry after a successful connection. HOT 1
- Cant receive data from websocket
- ws does not work in the browser. Browser clients must use the native WebSocket HOT 2
- TypeScript 5 claims IStompSocketMessageEvent and MessageEvent are incompatible HOT 3
- .
- Callback when a heartbeat has come or gone
- Pinging on demand HOT 1
- Connection closed when App is killed on Android HOT 1
- react native error: trust anchor for certification path not found, when trying stomp socket connection , i used @stomp/stompjs lib. any way to ignore sign certificate? HOT 1
- One and the same message is perceived as 2, with different ID but with the difference of one number at the end. HOT 3
- How to add httpOnly cookies to connectHeaders HOT 3
- Send a JSON object to the body when publishing HOT 1
- TypeError: WebSocket is not a constructor HOT 1
- Stomp auto make new connect after about 1 minute. HOT 1
- Rx-Stomp Invalid frame header Error
- Connection keep closing on React Native HOT 1
- Not working in React Native HOT 1
- Not compatible with Closure Compiler HOT 1
- STOMP redelivery policy on SUBSCRIBE doesn't work
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from stompjs.