I’m using Unity Transport 1.4.
I have an unreliable pipeline (NetworkPipeline.Null) and a reliable pipeline (ReliableSequencedPipelineStage) set up both on Server and Client.
The unreliable pipeline works both ways, but it seems the reliable pipeline works only one way (Server to Client).
I can send reliable messages over that pipeline and the Client receives those. The other way around I get a StatusCode.Success at the Client sending a message over the reliable pipeline but it never arrives at the Server.
I couldn’t really find anything relevant in the changelogs except for this in 2.0.0 exp 7:
"Fixed issues with ReliableSequencePipelineStage that would, in rare circumstances, lead to failure to deliver a reliable packet."
But it happens everytime all the time that the server doesn’t receive the reliable message.
Is this the same issue in 1.4.0?
Edit: Updated to Unity Transport 2.0.2 and the issue is still there. It seems like it’s pretty much impossible to debug on this end because there’s essentially nothing exposed that could be debugged. The message just never arrives.
Any chance you can share the code sending/receiving these messages?
Hi Simon, thanks for your answer. Was quite painful to track it down but I managed to find the issue.
When a message is sent with a byte array of length 0 then apparently the whole message is discarded without any error/warning:
var data = new byte[0];
var dataNative = new NativeArray<byte>(data, Allocator.Temp);
DataStreamWriter writer;
var result = driver.BeginSend(reliablePipeline, connection, out writer);
writer.WriteBytes(dataNative);
driver.EndSend(writer);
In my case I didn’t know that data was byte[0], the serializer that I use (Protobuf) apparently just discards bytes that are default values.
What I find weird about that is that the message is just discarded though. I would expect for it to be send normally and then return NetworkEvent.Type = Empty when popped or again throw a warning/error.
Oh that’s interesting. I was under the impression that we would send empty packets and report them back with a data event (and empty stream reader) to the receiver. Do you know if the packets you were sending on the unreliable pipeline were also empty? If so that would indicate a bug in the reliable pipeline, and is definitely something we’d want to fix.
Thanks for reporting back! Appreciate you taking the time to detail your findings.
I just tested it. Empty messages over the reliable pipeline are sent, but are tagged with NetworkEvent.Type = Data instead of Empty and a null stream reader.
Alright, thanks for testing it. Looks like we have a discrepancy in how we handle empty messages on different pipelines. I’ve filed a bug on our end to address this. Thanks for the report!
1 Like
Small update on this: we’ve identified a fix for the issue. It should be part of the next Unity Transport release (probably 2.1.0). With the fix applied, you’ll get a data event even for empty messages, no matter on which pipeline it is sent.