prekageo / rtmp-python

47 stars 21 forks source link

Connection to a Red5 Server #1

Open sebix opened 11 years ago

sebix commented 11 years ago

I'm trying to connect mit rtmp-python to a Red5 Serve but can't succeede. I'm using the folliwing Code (inspired by http://stackoverflow.com/questions/7415509/simple-rtmp-python-client):

   cl = rtmp_protocol.RtmpClient('#IP#', 1935, 'rtmp://#IP#/app', '#domain#', '#swf&referer#', 'app')
    cl.connect([])
    cl.call(proc_name='FCSubscribe')
    cl.call(proc_name='createStream')
    cl.call(proc_name='onFCSubscribe')
    cl.call(proc_name='play', parameters=['##ID##'])
    cl.handle_messages()

The data for the connection has been constructed from sniffed traffic. My script is hanging at this point:

  File "./sample_rtmp_client.py", line 28, in <module>
    main()
  File "./sample_rtmp_client.py", line 25, in main
    cl.handle_messages()
  File "/home/***/rtmp_protocol.py", line 520, in handle_messages
    msg = self.reader.next()
  File "/home/***/rtmp_protocol.py", line 87, in next
    header = rtmp_protocol_base.header_decode(self.stream)
  File "/home/***/rtmp_protocol_base.py", line 70, in header_decode
    channelId = stream.read_uchar()
  File "/usr/local/lib/python2.7/dist-packages/pyamf/util/pure.py", line 216, in read_uchar
    return ord(self._read(1))
  File "/usr/local/lib/python2.7/dist-packages/pyamf/util/pure.py", line 194, in _read
    bytes = self.read(length)
  File "/home/***/rtmp_protocol.py", line 23, in read
    return self.fileobject.read(length)
  File "/usr/lib/python2.7/socket.py", line 380, in read
    data = self._sock.recv(left)

I'm not familar with the RTMP Client Code and neither with the RTMP Protocol, so i'm asking here for a solution. Maybe I forgot a command, didn't use the lib correctly or it's a bug, I don't know.

prekageo commented 11 years ago

It's not actually hanging. It is waiting for the server to send something. The server does not respond in a timely manner probably because it was not given the correct commands. You have to consult the RTMP protocol documentation (http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/rtmp/pdf/rtmp_specification_1.0.pdf) in order to find out how to perform your task. I could help you if you provide me with adequate instructions and a public endpoint to your service.