Skip to content
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

connect to RTMP server after handshake, but get EOF error #1109

Open
Danrry opened this issue May 13, 2024 · 3 comments
Open

connect to RTMP server after handshake, but get EOF error #1109

Danrry opened this issue May 13, 2024 · 3 comments
Labels
question Further information is requested

Comments

@Danrry
Copy link

Danrry commented May 13, 2024

Hi:
I am using go2rtc lib with verison 1.9.1,to connect rtmp server for getting the video stream data. but I got the network error[EOF].

So I debug the code to find the error position. By learning RTMP protocol, I find there is no response data when sending the connection description to server after handshake stage. I don't know why it happens. Here is the code:

    rtmpURL := "rtmp://xxx:xxx/live/openUrl/WabN53"
	client, err := rtmp.DialPlay(rtmpURL)
	if err != nil {
		panic(err)
	}
	ret := client.GetMedias()
	fmt.Printf("%v\n", ret)

Debuging the further code, I find the first step of c.clienHandshake() is ok. The next step c.writePacketSize() is also ok. But the third step c.writeConnect() failed. After c.writeMessage(3, TypeCommand, 0, b) step, the error position is at c.readResponse(1).

func (c *Conn) writeConnect() error {
       b := amf.EncodeItems("connect", 1, map[string]any{
	    "app":      c.App,
            "flashVer": "LNX 9,0,124,2",
            "tcUrl": c.url,
            "fpad":  false,
            "capabilities": 15,
            "audioCodecs": 4071,
            "videoCodecs": 252,
            "videoFunction": 1
	})
	if err := c.writeMessage(3, TypeCommand, 0, b); err != nil {
		return err
	}

	v, err := c.readResponse(1)

        ... ...
}

Looking forward to your replies~

@AlexxIT AlexxIT added question Further information is requested labels May 13, 2024
@AlexxIT
Copy link
Owner

AlexxIT commented May 13, 2024

I don't understand where your get this code. Go2rtc don't have it.

@Danrry
Copy link
Author

Danrry commented May 14, 2024

Thank you for your replies. I am sorry to make you misunderstand.

The first part codes above are written in my project. The main intention is to access the remote RTMP server and get media information by creating RTMP client. They are from Go2rtc library at line 14: https://github.com/AlexxIT/go2rtc/blob/master/pkg/rtmp/client.go

The second part codes is in the further debug, which are from file at line 84 and 118: https://github.com/AlexxIT/go2rtc/blob/master/pkg/rtmp/client.go. The connecting stage of RTMP protocol is realized in the file at line 230: https://github.com/AlexxIT/go2rtc/blob/master/pkg/rtmp/conn.go . At first, I got EOF error after running the origin code. I doubted whether I missed some key information during the connecting stage. So I modified the sending description data, adding some fields. But it doesn't work.

I don't know why it happens. I check the codes and functions according to the RTMP protocol, including handshake, connection etc. But the server does not repsonse the expected message of "_result" command type . In contrast, I get the EOF error from network. Could you give me some suggestion?

@AlexxIT
Copy link
Owner

AlexxIT commented May 18, 2024

I can't be responsible for your code. There may be errors in it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants