rsocket-net
rsocket-net copied to clipboard
Improperly formed default mime type causes connection error when connecting to spring-boot rsocket server
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 !
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.
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
Also, you can use your custom data mime type by overriding the default. I will provide an example shortly
@broadside74 You may modify the default mime-type using the following RSocketClient constructor overload
var client = new RSocketClient(transport, new RSocketOptions() { DataMimeType = "application/json" })
closed with #21
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;

Which version has the BINARYMIMETYPE change?
I've tried changing the options as shown below, but the same error occurs;

Thanks!
@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
Oh, my bad, this change was not released yet, my apologies for the misleading comment. I will do a release shortly
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 Hi Oleg, I've tried the above but they seem to give the same error

@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 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

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 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 I'm unable to step into the nuget package from my console app, but I'm able to see the options here;

Here is an image of the whole client obj;

Hi @OlegDokuka
Is there any update on this or an ETA on the new release please?
Kind regards
@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
Hi @OlegDokuka,
I've tried solution you suggested and it works! :)

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