Skip to content
This repository has been archived by the owner on Feb 4, 2019. It is now read-only.

panic: runtime error: index out of range #1

Open
moneyzmey opened this issue Feb 2, 2018 · 17 comments
Open

panic: runtime error: index out of range #1

moneyzmey opened this issue Feb 2, 2018 · 17 comments

Comments

@moneyzmey
Copy link

Hi, use your example.

start stream using OBS.
got output:

2018/02/02 14:42:29 Serving RTMP on :1935
2018/02/02 14:42:38 Begin RTMP Handshake.
2018/02/02 14:42:38 Receive a C0 chunk.
2018/02/02 14:42:38 Send a S0 chunk.
2018/02/02 14:42:38 Receive a C1 chunk.
2018/02/02 14:42:38 Send a S1 chunk.
2018/02/02 14:42:38 Send a S2 chunk.
2018/02/02 14:42:38 Receive a C2 chunk.
2018/02/02 14:42:38 Set Chunk Size: 4096
2018/02/02 14:42:38 Catch AMF0 Command Message
2018/02/02 14:42:38 Receive connect command message (transactionID: 1.000000).
2018/02/02 14:42:38 Catch AMF0 Command Message
2018/02/02 14:42:38 Receive a releaseStream command (transactionID: 2.000000).
2018/02/02 14:42:38 Catch AMF0 Command Message
2018/02/02 14:42:38 Receive FCPublish command message (transactionID: 3.000000, streamName: 3818f59c-d7ad-40cf-ae16-a369589da90c).
2018/02/02 14:42:38 Catch AMF0 Command Message
2018/02/02 14:42:38 Catch createStream command message - (transactionID: 4.000000)
2018/02/02 14:42:38 Catch AMF0 Command Message
2018/02/02 14:42:38 Catch publish command message - (transactionID: 5.000000)
2018/02/02 14:42:38 Catch DataMessage(AMF0)
2018/02/02 14:42:39 Catch audio message
2018/02/02 14:42:39 Catch video message
2018/02/02 14:42:39 Catch video message
2018/02/02 14:42:39 Catch video message
2018/02/02 14:42:39 Catch video message
2018/02/02 14:42:39 Catch audio message
2018/02/02 14:42:39 Catch audio message
2018/02/02 14:42:39 Catch video message
2018/02/02 14:42:39 Catch audio message
2018/02/02 14:42:39 Catch video message
2018/02/02 14:42:39 Catch audio message
2018/02/02 14:42:39 Catch audio message
2018/02/02 14:42:39 Catch video message
2018/02/02 14:42:39 Catch audio message
2018/02/02 14:42:39 Catch video message
2018/02/02 14:42:39 Catch audio message
2018/02/02 14:42:39 Catch audio message
2018/02/02 14:42:39 Catch video message
2018/02/02 14:42:39 Catch audio message
2018/02/02 14:42:39 Catch video message
2018/02/02 14:42:39 Catch audio message
panic: runtime error: index out of range

goroutine 19 [running]:
encoding/binary.binary.bigEndian.Uint32(...)
	/usr/local/go/src/encoding/binary/binary.go:111
github.com/c-bata/rtmp.readMessageHeader(0xc4200960c0, 0xc420084c02, 0x0, 0x0, 0x0)
GolangProjects/src/github.com/c-bata/rtmp/chunk.go:246 +0x68e
github.com/c-bata/rtmp.readChunkHeader(0xc4200960c0, 0x1158e24, 0x13, 0x0)
GolangProjects/src/github.com/c-bata/rtmp/chunk.go:51 +0x67
github.com/c-bata/rtmp.(*conn).readChunk(0xc4200a6100, 0x0, 0x0)
GolangProjects/src/github.com/c-bata/rtmp/conn.go:196 +0x47
github.com/c-bata/rtmp.(*conn).serve(0xc4200a6100, 0xc4200c9000, 0x1000)
GolangProjects/src/github.com/c-bata/rtmp/conn.go:81 +0x102
created by github.com/c-bata/rtmp.(*Server).Serve
GolangProjects/src/github.com/c-bata/rtmp/server.go:56 +0x4dd
@c-bata
Copy link
Owner

c-bata commented Feb 2, 2018

Hmm... It's difficult to find the cause of this problem from the log you pasted. I need to check what bytes are sent from rtmp client.

Could you run the proxy and paste the output?

$ go run _example/server/main.go -addr :1936

After that

$ go run _example/proxy/main.go -laddr :1935 -raddr :1936
...

@moneyzmey
Copy link
Author

first example:

$ go run _example/server/main.go -addr :1936

output:

2018/02/06 14:55:16 Serving RTMP on :1936 (rev-)
2018/02/06 14:55:30 Begin RTMP Handshake.
2018/02/06 14:55:30 Receive a C0 chunk.
2018/02/06 14:55:30 Send a S0 chunk.
2018/02/06 14:55:30 Receive a C1 chunk.
2018/02/06 14:55:30 Send a S1 chunk.
2018/02/06 14:55:30 Send a S2 chunk.
2018/02/06 14:55:30 Receive a C2 chunk.
2018/02/06 14:55:30 Set Chunk Size: 4096
2018/02/06 14:55:30 Catch AMF0 Command Message
2018/02/06 14:55:30 Receive connect command message (transactionID: 1.000000).
2018/02/06 14:55:30 Catch AMF0 Command Message
2018/02/06 14:55:30 Receive a releaseStream command (transactionID: 2.000000).
2018/02/06 14:55:30 Catch AMF0 Command Message
2018/02/06 14:55:30 Receive FCPublish command message (transactionID: 3.000000, streamName: 3818f59c-d7ad-40cf-ae16-a369589da90c).
2018/02/06 14:55:30 Catch AMF0 Command Message
2018/02/06 14:55:30 Catch createStream command message - (transactionID: 4.000000)
2018/02/06 14:55:30 Catch AMF0 Command Message
2018/02/06 14:55:30 Catch publish command message - (transactionID: 5.000000)
2018/02/06 14:55:30 Catch DataMessage(AMF0)
2018/02/06 14:55:31 Catch audio message
2018/02/06 14:55:31 Catch video message
2018/02/06 14:55:31 Catch video message
2018/02/06 14:55:31 Catch unknown message type id: 135
2018/02/06 14:55:31 &rtmp.BasicHeader{FMT:0x0, ChunkStreamID:0x3a}
2018/02/06 14:55:31 &rtmp.MessageHeader{Timestamp:0xb23a6d, TimestampDelta:0x0, MessageLength:0x12c091, MessageTypeID:0x87, MessageStreamID:0x6d0d07e9}
2018/02/06 14:55:33 Catch unknown message type id: 0
2018/02/06 14:55:33 &rtmp.BasicHeader{FMT:0x3, ChunkStreamID:0x3f}
2018/02/06 14:55:33 &rtmp.MessageHeader{Timestamp:0x0, TimestampDelta:0x0, MessageLength:0x0, MessageTypeID:0x0, MessageStreamID:0x0}
2018/02/06 14:55:33 Catch unknown message type id: 0
2018/02/06 14:55:33 &rtmp.BasicHeader{FMT:0x3, ChunkStreamID:0x3f}
2018/02/06 14:55:33 &rtmp.MessageHeader{Timestamp:0x0, TimestampDelta:0x0, MessageLength:0x0, MessageTypeID:0x0, MessageStreamID:0x0}
2018/02/06 14:55:33 Catch unknown message type id: 0
2018/02/06 14:55:33 &rtmp.BasicHeader{FMT:0x3, ChunkStreamID:0x3f}
<CUT SOME PART LOG TOO BIG>
2018/02/06 14:55:33 &rtmp.MessageHeader{Timestamp:0x0, TimestampDelta:0x0, MessageLength:0x0, MessageTypeID:0x0, MessageStreamID:0x0}
2018/02/06 14:55:33 Catch unknown message type id: 0
2018/02/06 14:55:33 &rtmp.BasicHeader{FMT:0x3, ChunkStreamID:0x3f}
2018/02/06 14:55:33 &rtmp.MessageHeader{Timestamp:0x0, TimestampDelta:0x0, MessageLength:0x0, MessageTypeID:0x0, MessageStreamID:0x0}
2018/02/06 14:55:33 Catch unknown message type id: 0
2018/02/06 14:55:33 &rtmp.BasicHeader{FMT:0x3, ChunkStreamID:0x3f}
2018/02/06 14:55:33 &rtmp.MessageHeader{Timestamp:0x0, TimestampDelta:0x0, MessageLength:0x0, MessageTypeID:0x0, MessageStreamID:0x0}
2018/02/06 14:55:33 Catch unknown message type id: 0
2018/02/06 14:55:33 &rtmp.BasicHeader{FMT:0x3, ChunkStreamID:0x3f}
2018/02/06 14:55:33 &rtmp.MessageHeader{Timestamp:0x0, TimestampDelta:0x0, MessageLength:0x0, MessageTypeID:0x0, MessageStreamID:0x0}
panic: runtime error: index out of range

goroutine 19 [running]:
encoding/binary.binary.bigEndian.Uint32(...)
	/usr/local/go/src/encoding/binary/binary.go:111
github.com/c-bata/rtmp.readMessageHeader(0xc4200900c0, 0xc42018ef02, 0x0, 0x0, 0x0)
	/GolangProjects/src/github.com/c-bata/rtmp/chunk.go:246 +0x68e
github.com/c-bata/rtmp.readChunkHeader(0xc4200900c0, 0xc4200900c0, 0x122f7a8, 0x0)
	/GolangProjects/src/github.com/c-bata/rtmp/chunk.go:51 +0x67
github.com/c-bata/rtmp.(*conn).readChunk(0xc4200a0100, 0x0, 0x0)
	/GolangProjects/src/github.com/c-bata/rtmp/conn.go:196 +0x47
github.com/c-bata/rtmp.(*conn).serve(0xc4200a0100, 0xc4200c3000, 0x1000)
	/GolangProjects/src/github.com/c-bata/rtmp/conn.go:81 +0x102
created by github.com/c-bata/rtmp.(*Server).Serve
	/GolangProjects/src/github.com/c-bata/rtmp/server.go:56 +0x4dd

@c-bata
Copy link
Owner

c-bata commented Feb 6, 2018

Thank you for trying this. But sorry, could you paste the output of proxy? Maybe it's really long, so if you can't paste all output in this comment area, please paste the last two blocks of byte streams.

@moneyzmey
Copy link
Author

in process right now ;)

@moneyzmey
Copy link
Author

About proxy, i got connection refused.

output:

2018/02/06 15:09:01 Listening: :1935
2018/02/06 15:09:01 Proxying: :1936
2018/02/06 15:09:04 tcpproxy: for incoming conn 127.0.0.1:53189, error dialing ":1936": dial tcp :1936: getsockopt: connection refused

@c-bata
Copy link
Owner

c-bata commented Feb 6, 2018

Hmm....? Did you run rtmp server at :1936 port?

@moneyzmey
Copy link
Author

Yes, it my mistake, forgot to do it
last two blocks:

>>>>>>>>>>>>>>>>>>>> Source -> Destination >>>>>>>>>>>>>>>>>>>
00000000  44 00 00 07 00 01 d2 08  af 01 21 00 03 40 68 1b  |D.........!..@h.|
00000010  ff c0 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000060  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000070  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000080  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000090  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000100  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000110  00 00 00 00 00 00 00 00  00 00 00 00 00 00 37 d5  |..............7.|
00000120  80 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000130  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000140  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000150  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000160  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000170  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000180  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000190  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001d0  00 00 00 00 00 00 00 00  00 70                    |.........p|

>>>>>>>>>>>>>>>>>>>> Source -> Destination >>>>>>>>>>>>>>>>>>>
00000000  44 00 00 17 00 01 d3 08  af 01 21 00 03 40 68 1b  |D.........!..@h.|
00000010  ff c0 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000020  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000040  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000050  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000060  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000070  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000080  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000090  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000d0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000e0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000000f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000100  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000110  00 00 00 00 00 00 00 00  00 00 00 00 00 00 37 d6  |..............7.|
00000120  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000130  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000140  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000150  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000160  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000170  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000180  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
00000190  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001a0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001b0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001c0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
000001d0  00 00 00 00 00 00 00 00  00 00 70                 |..........p|

@c-bata
Copy link
Owner

c-bata commented Feb 6, 2018

Thank you. I'll check the bytes.
It may take a while, but please wait.

@moneyzmey
Copy link
Author

Sure, thank you so much!

@moneyzmey
Copy link
Author

add full log file
testlogfile.zip

@c-bata
Copy link
Owner

c-bata commented Feb 6, 2018

Thank you. great job!

@moneyzmey
Copy link
Author

May I ask your email address ?

@c-bata
Copy link
Owner

c-bata commented Feb 6, 2018

Sorry, no soliciting is allowed.

@moneyzmey
Copy link
Author

ok, understood.

@moneyzmey
Copy link
Author

Do you have any idea ?

@gizmocuz
Copy link

Same problem here...

@c-bata
Copy link
Owner

c-bata commented Jun 25, 2018

@saturday06 tells me the cause of this problem might be below:

  1. When FMT field in chunk basic header is 2 or 3, we need to re-use chunk data from the previous received one.
  2. Sometimes the length of chunk data doesn't match that client sends.

I don't know how can I fix the second one. But anyway, I'll investigate this problem again.
Thanks

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants