Skip to content
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

Improperly formed default mime type causes connection error when connecting to spring-boot rsocket server #20

Open
aboccag opened this issue Sep 6, 2020 · 18 comments · Fixed by #21

Comments

@aboccag
Copy link
Contributor

aboccag commented Sep 6, 2020

Hi everyone,

I have a Spring Boot RSocket server and I am unable to connect to it with your example. I got a rejected Setup :
0000 Error {000}: [00000003] Invalid mime type "binary": does not contain '/'
I tried some options in RSocketOptions but alyaws the same error

Here is my spring server config :

spring:
  rsocket:
    server:
      port: 7000
      transport: tcp

Here is my dotnet program

var client = new RSocketClient(new SocketTransport("tcp://localhost:7000"), new RSocketOptions(){ InitialRequestSize = 3 });
			//var client = new RSocketClient(new WebSocketTransport("ws://localhost:9092/"), new RSocketOptions() { InitialRequestSize = 3 });
			//var client = new RSocketClient(loopback);
			await client.ConnectAsync();

The server is working, I did manage to handle RSocket data with another spring boot client.

Thanks for your help !

@aboccag
Copy link
Contributor Author

aboccag commented Sep 7, 2020

Well, it feels like the problem comes from the library in the RSocketOptions.cs file :

	public class RSocketOptions
	{
		public const int INITIALDEFAULT = int.MinValue;
		public const string BINARYMIMETYPE = "binary";

		public TimeSpan KeepAlive { get; set; }
		public TimeSpan Lifetime { get; set; }
		public string DataMimeType { get; set; }
		public string MetadataMimeType { get; set; }

		public int InitialRequestSize { get; set; } = 10;
		public int GetInitialRequestSize(int initial) => (initial <= INITIALDEFAULT) ? InitialRequestSize : initial;


		public static readonly RSocketOptions Default = new RSocketOptions()
		{
			KeepAlive = TimeSpan.FromMinutes(1),
			Lifetime = TimeSpan.FromMinutes(3),
			DataMimeType = BINARYMIMETYPE,
			MetadataMimeType = BINARYMIMETYPE,
		};
	}

I Changed

public const string BINARYMIMETYPE = "binary";

to

public const string BINARYMIMETYPE = "application/x-protobuf";

now the next problem is how to deserialize in the spring boot application.

@OlegDokuka
Copy link
Member

OlegDokuka commented Sep 7, 2020

Hi @broadside74 !

We have improperly formed mime-type which should be application/octet-stream instead of binary

Thanks for finding that. Feel free to create a PR or otherwise I will do that shortl.

Cheers,
Oleh

@OlegDokuka
Copy link
Member

Also, you can use your custom data mime type by overriding the default. I will provide an example shortly

@OlegDokuka
Copy link
Member

@broadside74 You may modify the default mime-type using the following RSocketClient constructor overload

var client = new RSocketClient(transport, new RSocketOptions() { DataMimeType = "application/json" })

@OlegDokuka
Copy link
Member

closed with #21

@OlegDokuka OlegDokuka changed the title RSOcket transport connect TCP Server Improperly formed default mime type causes connection error when connecting to spring-boot rsocket server Sep 8, 2020
@foyss
Copy link

foyss commented Feb 5, 2021

Hi everyone,

I'm currently using v0.2.7 from Nuget Package Manager, and the RSocketOptions class in there has the BINARYMIMETYPE set to "binary", throwing me the same error;

image

Which version has the BINARYMIMETYPE change?

I've tried changing the options as shown below, but the same error occurs;

image

Thanks!

@OlegDokuka
Copy link
Member

@foyss can you please check if you really use the latest one since right now RSocketOptions has a different value set -> https://github.com/rsocket/rsocket-net/blob/master/RSocket.Core/RSocketOptions.cs#L17

@OlegDokuka
Copy link
Member

Oh, my bad, this change was not released yet, my apologies for the misleading comment. I will do a release shortly

@OlegDokuka
Copy link
Member

OlegDokuka commented Feb 5, 2021

I've tried changing the options as shown below, but the same error occurs;

@foyss can you try setting MetadataMimeType as message/x.rsocket.composite-metadata.v0 and DataMimeType as text/plain or application/octet-stream

@foyss
Copy link

foyss commented Feb 5, 2021

@OlegDokuka Hi Oleg, I've tried the above but they seem to give the same error

image

@OlegDokuka
Copy link
Member

@foyss can you please enable the following logger

<logger name="io.rsocket.FrameLogger" level="DEBUG"/>

and share what is coming to the spring server

@foyss
Copy link

foyss commented Feb 5, 2021

@OlegDokuka My colleague is unsure on how to enable the following logger on Spring Boot, but the following is shown in the console log once I try to .RequestStream

image

@foyss
Copy link

foyss commented Feb 5, 2021

I've set up the FrameLogger and set the level to DEBUG, but the console message seems to report to same message as above

@OlegDokuka
Copy link
Member

@foyss can you please set a breakpoint at this line -> https://github.com/rsocket/rsocket-net/blob/master/RSocket.Core/RSocketClient.cs#L25

and say what is in the given options

@foyss
Copy link

foyss commented Feb 5, 2021

@OlegDokuka I'm unable to step into the nuget package from my console app, but I'm able to see the options here;

image

Here is an image of the whole client obj;

image

@foyss
Copy link

foyss commented Feb 8, 2021

Hi @OlegDokuka

Is there any update on this or an ETA on the new release please?

Kind regards

@OlegDokuka OlegDokuka reopened this Feb 12, 2021
@OlegDokuka
Copy link
Member

OlegDokuka commented Feb 12, 2021

@foyss can you try passing options directly into ConnectAsync

var client = new RSocketClient(new WebSocketTransport("ws://127.0.0.1:7000/quotes"));

await client.ConnectAsync(new RSocketOptions() { 
    InitialRequestSize = 3,
    DataMimeType = "application/x-binary",
    MetadataMimeType = "application/x-binary"
});

that should fix your problem

@foyss
Copy link

foyss commented Feb 12, 2021

Hi @OlegDokuka,

I've tried solution you suggested and it works! :)
image

Saves me from recompiling it. Thanks for the help

Reference: https://stackoverflow.com/questions/66157652/c-sharp-net-rsocket-client-invalid-mime-type-binary-with-java-rsocket-server/66169431#66169431

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

Successfully merging a pull request may close this issue.

3 participants