rsocket-net icon indicating copy to clipboard operation
rsocket-net copied to clipboard

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

Open aboccag opened this issue 5 years ago • 18 comments

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 avatar Sep 06 '20 10:09 aboccag

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.

aboccag avatar Sep 07 '20 12:09 aboccag

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 avatar Sep 07 '20 13:09 OlegDokuka

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

OlegDokuka avatar Sep 07 '20 14:09 OlegDokuka

@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 avatar Sep 07 '20 19:09 OlegDokuka

closed with #21

OlegDokuka avatar Sep 08 '20 06:09 OlegDokuka

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!

foyss avatar Feb 05 '21 12:02 foyss

@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 avatar Feb 05 '21 12:02 OlegDokuka

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

OlegDokuka avatar Feb 05 '21 12:02 OlegDokuka

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

OlegDokuka avatar Feb 05 '21 12:02 OlegDokuka

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

image

foyss avatar Feb 05 '21 12:02 foyss

@foyss can you please enable the following logger

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

and share what is coming to the spring server

OlegDokuka avatar Feb 05 '21 13:02 OlegDokuka

@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 avatar Feb 05 '21 13:02 foyss

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

foyss avatar Feb 05 '21 17:02 foyss

@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

OlegDokuka avatar Feb 05 '21 17:02 OlegDokuka

@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 avatar Feb 05 '21 18:02 foyss

Hi @OlegDokuka

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

Kind regards

foyss avatar Feb 08 '21 11:02 foyss

@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

OlegDokuka avatar Feb 12 '21 09:02 OlegDokuka

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

foyss avatar Feb 12 '21 14:02 foyss