PDA

View Full Version : Problem with GetSockError


gorilla.maguila
03-04-2014, 04:34 PM
Every time I try to dump:

rtmpdump -r rtmp://31.220.0.138:1935/redirect/actionx -W http://p.jwpcdn.com/6/8/jwplayer.flash.swf -p http://www.eucast.tv/embed.php?le=actionx --live --debug


I get a GetSockError:

DEBUG: Protocol : RTMP
DEBUG: Hostname : 31.220.0.138
DEBUG: Port : 1935
DEBUG: Playpath : actionx
DEBUG: tcUrl : rtmp://31.220.0.138:1935/redirect
DEBUG: swfUrl : http://p.jwpcdn.com/6/8/jwplayer.flash.swf
DEBUG: pageUrl : http://www.eucast.tv/embed.php?le=actionx
DEBUG: app : redirect
DEBUG: live : yes
DEBUG: timeout : 30 sec
DEBUG: SWFSHA256:
DEBUG: ab 9a e6 97 d7 bd 16 16 cc 22 fc 6e e4 d6 67 fa
DEBUG: cc 32 0e bc 46 42 dc ea 22 4a f4 83 db 93 47 d2
DEBUG: SWFSize : 320072
DEBUG: Setting buffer time to: 36000000ms
Connecting ...
DEBUG: RTMP_Connect1, ... connected, handshaking
DEBUG: HandShake: Client type: 03
DEBUG: HandShake: Client digest offset: 417
DEBUG: HandShake: Initial client digest:
DEBUG: 65 08 c8 ae 10 5f a1 d0 0a 0c 71 47 38 f5 3c 6a
DEBUG: 41 d6 d7 9a ca e2 c0 86 69 55 fd a8 7b d5 45 05
DEBUG: RTMPSockBuf_Fill, recv returned -1. GetSockError(): 104 (Connection reset by peer)
ERROR: RTMP_Connect1, handshake failed.
DEBUG: Closing connection.

But right after this fails I try again to dump with the same parameters:

rtmpdump -r rtmp://31.220.0.138:1935/redirect/actionx -W http://p.jwpcdn.com/6/8/jwplayer.flash.swf -p http://www.eucast.tv/embed.php?le=actionx --live --debug


And magically works...

DEBUG: Protocol : RTMP
DEBUG: Hostname : 31.220.0.138
DEBUG: Port : 1935
DEBUG: Playpath : actionx
DEBUG: tcUrl : rtmp://31.220.0.138:1935/redirect
DEBUG: swfUrl : http://p.jwpcdn.com/6/8/jwplayer.flash.swf
DEBUG: pageUrl : http://www.eucast.tv/embed.php?le=actionx
DEBUG: app : redirect
DEBUG: live : yes
DEBUG: timeout : 30 sec
DEBUG: SWFSHA256:
DEBUG: ab 9a e6 97 d7 bd 16 16 cc 22 fc 6e e4 d6 67 fa
DEBUG: cc 32 0e bc 46 42 dc ea 22 4a f4 83 db 93 47 d2
DEBUG: SWFSize : 320072
DEBUG: Setting buffer time to: 36000000ms
Connecting ...
DEBUG: RTMP_Connect1, ... connected, handshaking
DEBUG: HandShake: Client type: 03
DEBUG: HandShake: Client digest offset: 417
DEBUG: HandShake: Initial client digest:
DEBUG: 4b a9 eb 0e 7a b3 15 57 ae 92 cd da 35 4e 4d c2
DEBUG: 12 ce ed e5 fa d8 f4 d8 39 1d 54 d0 6c a0 de bc
DEBUG: HandShake: Type Answer : 03
DEBUG: HandShake: Server Uptime : 96850052
DEBUG: HandShake: FMS Version : 3.0.1.1



So first attempt fails and second attempt works, and this happens everytime. I've tried changing my IP, trying under other machines to check if I'm somehow geoblocked with the same two attempts result.

Can anybody enlighten me?

gorilla.maguila
03-06-2014, 03:49 AM
Here is a tcpdump capture of an unsuccessful session:

http://www.cloudshark.org/captures/b0c01d8de085

It seems that on RTMP_Connect0 the socket gets an ACK timeout and tries to retransmit two more times.

Then on RTMP_Connect1 receives a response of the two retransmitted packets in the form of a reset packet, hence fails.

Maybe forcing a SO_KEEPALIVE flag on RTMP_Connect0 to avoid retransmission solves it.

gorilla.maguila
03-06-2014, 07:40 AM
Solved with a small workaround in rtmpdump.c:



+ #define RTMP_CONNECT_RETRIES 5

- if (!RTMP_Connect(&rtmp, NULL))
- {
- nStatus = RD_NO_CONNECT;
- break;
- }

+ int i = 0;
+ result = 0;

+ for(i = 0; i < RTMP_CONNECT_RETRIES; i++){
+ if((result = RTMP_Connect(&rtmp, NULL)) == 1)
+ break;
+ }

+ if(!result)
+ break;

KSV
03-06-2014, 08:30 AM
why do you think it was an issue with rtmpdump? it could be an issue with server configuration which is rejecting first connection attempt.

gorilla.maguila
03-06-2014, 08:37 AM
why do you think it was an issue with rtmpdump? it could be an issue with server configuration which is rejecting first connection attempt.

It is only a workaround not be mainlained upstream.

The problem seems to be somewhere else because dumping the swf client session it is not triggering any reconnect, the swf client manages to connect at first attempt.