Closed maximilianosinski closed 7 months ago
.
binaryreader and binarywriter are endian aware. All packets to Spotify are required to be in Big-Endian byte order.
Code running in JVM is already Big-Endian. But .NET most likely does stuff in Little-Endian.
Hence I advise against using BinaryReader/Writer and just writing bytes directly to the output stream.
Reference: https://learn.microsoft.com/en-us/dotnet/api/system.io.binaryreader.readuint16?view=net-8.0
`Reads a 2-byte unsigned integer from the current stream using little-endian encoding and advances the position of the stream by two bytes.
im using the stream only now, and im receiving a other error: System.IO.EndOfStreamException: Unable to read beyond the end of the stream.
Span<byte> header = new byte[3];
_conn.Stream.ReadExactly(header);
this in the receive function, any idea?
Spotify probably closed the stream because you sent it invalid data. Is your Receive/Send function thread safe? Make sure it cannot be hit more than once at a team (its a blocking function)
Also for both send and receive you are starting at sequence=1, it should always start at 0
okay, so im incrementing the sequences at the end of the functions, so the first send and receive will have 0, no success. my send and receive should be correct, it's 1:1 the same from your code, and as you said i maybe sent invalid data, this could be, im trying to authenticate with username and password, do you have a code example for that?
i actually had the wrong field numbers in my protobuf-files, and now it works!
other, question do you have the stream reporting in your code? (context changed, etc) i can't seem to find it.
I've been successful in making connection through TCP in C#. you can find the connection code here: https://github.com/christosk92/Wavee/blob/main/src/Wavee.Spfy/DefaultServices/DefaultTcpClient.cs