Your client needs to send the routing information that spring-boot makes it decisions off. See https://domenicosibilio.medium.com/rsocket-with-spring-boot-js-zero-to-hero-ef63128f973d
Specifically look at the mime type in setting up the client, and the route which should match the @MessageMapping your your code.
// Create an instance of a client
client = new RSocketClient({
serializers: {
data: JsonSerializer,
metadata: IdentitySerializer
},
setup: {
// ms btw sending keepalive to server
keepAlive: 60000,
// ms timeout if no keepalive response
lifetime: 180000,
// format of `data`
dataMimeType: 'application/json',
// format of `metadata`
metadataMimeType: 'message/x.rsocket.routing.v0',
},
transport: new RSocketWebSocketClient({
url: 'ws://localhost:8080/tweetsocket'
}),
});
// Open the connection
client.connect().subscribe({
onComplete: socket => {
// socket provides the rsocket interactions fire/forget, request/response,
// request/stream, etc as well as methods to close the socket.
socket.requestStream({
data: {
'author': document.getElementById("author-filter").value
},
metadata: String.fromCharCode('tweets.by.author'.length) + 'tweets.by.author',
}).subscribe({
onComplete: () => console.log('complete'),
onError: error => {
console.log(error);
addErrorMessage("Connection has been closed due to ", error);
},
onNext: payload => {
console.log(payload.data);
addMessage(payload.data);
},
onSubscribe: subscription => {
subscription.request(2147483647);
},
});
},
onError: error => {
console.log(error);
addErrorMessage("Connection has been refused due to ", error);
},
onSubscribe: cancel => {
/* call cancel() to abort */
}
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…