-
-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
WebRTC: TCP transport should use read_fully instead of read. v5.0.194 v6.0.94 #3847
WebRTC: TCP transport should use read_fully instead of read. v5.0.194 v6.0.94 #3847
Conversation
you do it wrong, use read_fully instead of read, you use read instead of read_fully |
7349441
to
f24ea28
Compare
Sorry, I misunderstood earlier and have made some changes. Could you please create a simple demo to test it? @sandro-qiang
|
我用gpt写了个golang demo,使用TCP NODELAY选项发送单个字节的情况 package main
import (
"fmt"
"net"
"time"
)
func main() {
// Set server address and port
serverAddr := "localhost:8000"
// connect server
conn, err := net.Dial("tcp", serverAddr)
if err != nil {
fmt.Println("cannot connect server:", err)
return
}
defer conn.Close()
// Send a single byte of data
data := []byte{0x01}
_, err = conn.Write(data)
if err != nil {
fmt.Println("data send fail:", err)
return
}
fmt.Println("data send success")
time.Sleep(time.Second)
fmt.Println("test finish.")
} SRS调用
|
This test cannot reproduce the problem, because whether you turn on no-delay or not, you only sent one byte, so the read packet length will always fail.
|
Perhaps you can try this: send one byte, then wait for 5 seconds, and send another byte. The srs server will print the packet length. The printed lengths in these two situations will definitely be different. Moreover, the printed length from the 'read' operation is incorrect because it only read one byte. |
Need to merge into 5 and 6 @xiaozhihong
|
…#3847) SRS supports TCP WebRTC by reading 2 bytes of length, like `read(buf, 2)`. However, in some cases, it might receive 1 byte, causing subsequent data to be incorrect and making it unable to push or play streams. --------- Co-authored-by: john <hondaxiao@tencent.com>
…ossrs#3847) SRS supports TCP WebRTC by reading 2 bytes of length, like `read(buf, 2)`. However, in some cases, it might receive 1 byte, causing subsequent data to be incorrect and making it unable to push or play streams. --------- Co-authored-by: john <hondaxiao@tencent.com>
SRS supports TCP WebRTC by reading 2 bytes of length, like
read(buf, 2)
. However, in some cases, it might receive 1 byte, causing subsequent data to be incorrect and making it unable to push or play streams.Co-authored-by: john hondaxiao@tencent.com