Skip to content

RSocketResumableTransport with RSocketWebSocketClient and spring backend? #53

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

Closed
jeisea opened this issue Sep 30, 2019 · 14 comments
Closed

Comments

@jeisea
Copy link

jeisea commented Sep 30, 2019

Hi, I tried following the example for the ResumableTransport, but subscribing to the connection never hits onComplete. The main difference is that I'm using the RSocketWebSocketClient and a spring backend which means my setup for the client looks like this

	serializers: {
		data: JsonSerializer,
		metadata: IdentitySerializer
	},
	setup: {
		keepAlive: 60000,
		lifetime: 180000,
		dataMimeType: 'application/json',
		metadataMimeType: 'message/x.rsocket.routing.v0',
	},

No errors in server logs or browser console logs.

Thanks!

EDIT: Was poking around rsocket-java issues and found rsocket/rsocket-java#602 which seems to be referring to the same issue. Feel free to close if you feel my post is redundant.

@bclozel
Copy link

bclozel commented Oct 1, 2019

I believe this issue is a duplicate of #49, as routing and composite metadata frames will be covered there. Also, it's not clear from your description which Spring and RSocket Java versions you are using.

If you're using the latest ones, the server should fail while parsing the routing metadata since the client will not be writing it correctly. The routing metadata must be parsed and written in a specific way and the IdentitySerializer won't work here.

Here's a custom serializer you can use in the meantime:

import {
    createBuffer,
    byteLength
} from 'rsocket-core';

/**
 * Serializer for Routing metadata
 * @see https://github.com/rsocket/rsocket/blob/master/Extensions/Routing.md
 */
export class RoutingMetadataSerializer {

    deserialize(data) {
        if (data == null) {
            return null;
        }
        return data.toString('utf8', 1, data.length);
    }

    serialize(data) {
        if (data == null) {
            return null;
        }
        let dataLength = byteLength(data, 'utf8');
        let outBuffer = createBuffer(1 + dataLength);
        outBuffer.writeUInt8(dataLength, 0);
        outBuffer.write(data, 1, data.length, 'utf8');
        return outBuffer;
    }
}

RoutingMetadataSerializer.MIME_TYPE = "message/x.rsocket.routing.v0";
RoutingMetadataSerializer.MIME_TYPE_ID = 0x7E;

@jeisea
Copy link
Author

jeisea commented Oct 1, 2019

Sorry if I wasn't clear enough. I am using spring 2.2m4 so the metadata setup I posted works fine for now.

It works just fine when I give the RSocketClient an RSocketWebSocketClient for the transport. The problem I am facing is when I give the RSocketClient an RSocketResumableTransport that has been supplied with an RSocketWebSocketClient.

The current example rsocketjs provides in packages/examples/ResumeClient is quite different from my use case and I was questioning my config.

@robertroeser
Copy link
Member

@jeisea rsocket-js needs a new version released - we are hoping to get that done shortly and then it should work with java resumption.

@robertroeser
Copy link
Member

Hi @jeisea rsocket-js 1.1 has been released. Can you try it and see if it fixes your issue?
https://www.npmjs.com/package/rsocket-core

@jeisea
Copy link
Author

jeisea commented Oct 14, 2019

Hi @robertroeser , I tried upgrading to 0.0.11 today and I think the package that was published might have been missing something.

After my npm install, my app no longer found the rsocket dependencies and when I checked node_modules, rsocket-core and rsocket-websocket-client only contained package.json.

Would be great to know if it's a me issue or an npm issue.
Thanks!

@robertroeser
Copy link
Member

@stevegury do you need to release other packages as well?

@stevegury
Copy link
Member

stevegury commented Oct 18, 2019

@robertroeser @jeisea I released a new version (0.0.13), I think this one should be ok. Apologies for the trouble.

@maxim-bandurko-lsvt
Copy link

Hello @stevegury . Issue with release still exists. There is a mention here also:
#58
Thanks!

@stevegury
Copy link
Member

@maxim-bandurko-lsvt sorry for the trouble, could you try again with 0.0.16?

@maxim-bandurko-lsvt
Copy link

@stevegury It worked well, thank you!
Have on more question, there are 2 versions at npm:
https://www.npmjs.com/package/rsocket-websocket-client/v/0.0.16
https://www.npmjs.com/package/rsocket-websocket-client/v/0.1.0-alpha.0ddeeafe
Wanted to check, what version is most recent one? and what differences can be? May be it make sense to start using v0.1.0?

@stevegury
Copy link
Member

Please use 0.0.16, v0.1.0-alpha is an experimental version based on 0.0.13 codebase.

@stevegury stevegury reopened this Oct 22, 2019
@maxim-bandurko-lsvt
Copy link

@stevegury I see. ok, thank you!

@maxim-bandurko-lsvt
Copy link

@robertroeser I've tried 'message/x.rsocket.routing.v0' with latest release and it works perfect! Thank you!

@jeisea
Copy link
Author

jeisea commented Oct 23, 2019

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants