-
Notifications
You must be signed in to change notification settings - Fork 100
Provide simple websocket example #21
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
Comments
Does your server support the rsocket protocol? Note that rsocket is a higher level protocol that can use websocket as a transport - neither the client or server can start pushing arbitrary data to the other (as in your WS example) unless it initiates one of the defined actions (request-response, request-stream, etc). In this case the client would typically make a requestResponse with a payload indicating the data it is requesting, and the server would reply with one response (to send multiple payloads use request stream). The corresponding response payload would be accessible via the onComplete handler to requestResponse (missing in your second example). |
@josephsavona It must not. There is an open ticket for WebFlux to support it, so I guess I'll have to wait until that's finished. |
I think this has been a point of confusion twice now. We should probably make this clearer in the docs if it comes up again. |
I'm the 3rd |
I also ran into difficulties getting rsocket to work over WebSockets using a Spring back-end. I ran into this issue so in case anyone needs it here is what I did. In Java:
In JavaScript:
Key part is the |
@eriktim for me this is not working.
First 8 bits represent the size of content by doc link you provided (10 being the length of route name). That is not handled by IdentitySerializer. |
Also, if you want to send metadata as json object then: RSocketStrategies rSocketStrategies = applicationContext.getBean(RSocketStrategies.class);
DefaultMetadataExtractor defaultMetadataExtractor = (DefaultMetadataExtractor) rSocketStrategies.metadataExtractor();
defaultMetadataExtractor
.metadataToExtract(
MimeTypeUtils.APPLICATION_JSON,
new ParameterizedTypeReference<Map<String, Object>>() {},
(metadata, headers) -> metadata.entrySet().forEach(entry -> headers.put(entry.getKey(), entry.getValue()))
); Now you only need to have |
@mmihael Were you able to get this working in ie11? On ie11, client.connect() never completes for me. This is using the same setup as @eriktim with your metadata fix. Any help would be greatly appreciated. Thanks! EDIT: This might be due to some change in rsocketjs recently? I have one app using an older version where I am setting metadata like Erik and it completes the connection fine in ie11. I completion issue occurs in my app using the current version of rsocket js. |
I have a simple websocket example that I'm trying to implement with rsocket-js (since I'm connecting to a Spring WebFlux-powered websocket endpoint).
This works using plain ol' websockets:
From the current docs, I figured this is equivalent to the following.
However, I don't get any console logs when I trigger a new websocket event.
Related: does rsocket-js support sending an authorization header in the request like socket.io-client does?
The text was updated successfully, but these errors were encountered: